-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Support for WhatsApp Channel via WhatsApp Cloud API #676
base: master
Are you sure you want to change the base?
Conversation
Hello @slvnperron, just wanted to kindly check in on this PR. It’s been some time, and I’m eager to contribute further based on any feedback. Thanks in advance for your time and review! |
hey @ivarunseth, thanks for contributing, sorry for the late response I will verify your request with the team and get back to you Question, do you know how to use a custom build of the messaging server on the current distributed Botpress binaries so you can access your features right away? it should be possible to do just by replacing the binary from the /bin folder from your docker image (at /botpress) or Botpress folder |
Hey @davidvitora, thanks for your time to view the PR! To answer your question, I have built the binaries of messaging server locally using I m yet to build it using docker and verify the same. Please note that I had to add whatsapp in channelName array in the MessagingInteractor class located in v12/packages/bp/src/core/messaging/subservices/interactor.ts file in the v12 repository to make it work. Looking forward to work on any comments after review. Thanks! |
I saw that you didn't implement the Card or Carrousel renderers, the way we do it at Twilio or Vonage (Which can connect to WhatsApp) is to send multiple messages (Since sending a real Card or Carousel requires approving a template with Meta), do you want to add the same to this Channel? If you don't, there is no issue with that, we just won't be able to merge this to this Repo, which in the end of the day shouldn't make much difference for you, since v12 is on LTS and we are just pushing Bugs/Security updates, meaning you would need to compile and use a custom version from the messaging server with your Botpress core |
Hey, I just saw how card & carousel renderers are implemented in twilio and vonage channels. As you mentioned, since sending templated messages requires approval from meta, I had not implemented the carousel renderer. Since this PR is with respect to open issue #504 I will be making required changes as soon as possible. Thanks! |
…rt for say_something, postback & open_url actions for carousel content.
…whatsapp will preview the webpage.
…ilar to Twilio & Vonage channels. Handled constraints for content length of button title, body text etc.
Hi @ivarunseth any updates on this ? Is this working fine or their are any issues with this ? |
Hey @davidvitora, @Akshat7321, As of now, apart from card and carousel content types, everything is working. I'm implementing the card and carousel content types using interactive reply buttons and list messages in Whatsapp Cloud API since it does not require approval from Meta unlike template messages (discussed earlier). In case the content generated by a bot developer does not follow the post request parameters of the API, I'm falling back to the approach used in twilio and vonage messaging channels. Once finished, I will test the code and address any additional feedback if needed. |
Hi @ivarunseth, could you please tell me how to stop the existing messaging channel and run these channels using Docker Compose? Where I have to make changes? |
Hello @AnshuChatbot, When you make changes to messaging channels, run Assuming you have replaced some existing messaging channel, you should be able to use this image with docker compose to run the services. |
I am able to run these messaging channels in a separate container, but I'm unable to attach them to our running host. Could you suggest how to remove the existing channel? |
In that case, you should check if the image and port bindings are correct in your |
@ivarunseth,Ok can you have any documentation that how to remove the existing messaging channel and attach these one if available please provide me ? I have no idea from where we remove the by default messaging launcher that are running in port 3100 . |
…e else using fallback logic.
…t request parameters.
…sed while rendering choice or carousel.
Hello @davidvitora, I have completed the card, carousel & choices implementation. Awaiting your feedback, please review :) Thanks! |
Hey @ivarunseth, Nice, as soon as I get a chance to look at it I will let you know Could you also document the setup for this channel just like we did for Twillio and others? I want make sure that i'm able to setup and test this channel |
hey @AnshuChatbot, you need to build the messaging server as a binary (details on it is done can be find at our github actions workflows, but you need to do on your machine), then you can just replace the messaging server binary in your Botpress server at BOTPRESS_ROOT/bin |
@ivarunseth I am done same thing but still I am facing bug that are internal server 500 and the error is look like these |
Hey @AnshuChatbot, I see you were able to build the messaging server, and connect your bot to whatsapp messaging channel. Could you please share the messaging channel config in your bot configuration for whatsapp? This is a sample messaging channel config you need to add in bot.config.json file,
I believe you did not add "version" key with "1.0.0" value in the object which is causing the issue. Also, if you are still facing issue in interactor.ts file, there is private variable "channelNames", you just need to add "whatsapp" in the list. I hope this helps! |
@ivarunseth I am getting the below information in the log. Is there any things in the /messaging-whatsapp-channel/packages/channels/src/whatsapp/channel.ts this file that I have to change to proceed ahead here the logs |
Hey @AnshuChatbot, You are facing an error when making a post request to whatsapp messages API. The request is intended to mark a user message as read by the bot. I had implemented the The request body structure and parameters looks correct to me, but you still got 400 status code. This could mean something is wrong with the channel configuration in your bot. Have you created an app on Meta platform and setup the whatsapp product? You will have to configure the webhook of bot in a meta application and subscribe for messages event. Assuming you are running this locally, you can follow the steps below to integrate your bot with whatsapp --
If everything is correct, botpress will expose a webhook of your bot which you can find in logs like this,
Please share further logs if you still face issue with the API. |
Hello @davidvitora, Sure I will add the documentation asap, meanwhile you can use the same steps above for the setup and testing. Thanks! |
Hey @ivarunseth, I'm encountering an issue after setting up messaging through WhatsApp. Although ngrok shows a status code 200, I'm facing a bug when I set markRead to true. When this is enabled, I get error logs, but if I set markRead to false, no errors appear. However, in that case, the response from the bot doesn't get displayed in whatsapp . Here are the error logs that appear when markRead is set to true: |
Hey, @AnshuChatbot. You are getting 400 Bad Request from the Whatsapp Messages API. Without the error message from the API, I won't be able to help you. I suggest you try hitting the Meta's API endpoint with your credentials and same payload on Postman, you will see exactly what is wrong in your configuration. |
This pull request introduces support for integrating WhatsApp as a messaging channel in the Botpress Messaging Server, leveraging the WhatsApp Cloud API. The implementation enables chatbot interactions on WhatsApp, expanding the platform's reach and providing users with a popular and widely used communication medium.
Key Features:
Implementation Details:
WhatsApp API Client:
Message Handling:
Renderer Support:
Documentation:
Testing:
Future Work:
Notes:
By integrating WhatsApp, this update significantly enhances the versatility and usability of the Botpress Messaging Server, enabling developers to create richer, more engaging chatbot experiences. Looking forward to feedback and suggestions for further enhancements.