microsoft / botbuilder-dotnet

Welcome to the Bot Framework SDK for .NET repository, which is the home for the libraries and packages that enable developers to build sophisticated bot applications using .NET.
https://github.com/Microsoft/botframework
MIT License
872 stars 479 forks source link

Does Bot Composer work with Twilio WhatsApp Adapter? #5113

Closed hsachinraj closed 3 years ago

hsachinraj commented 3 years ago

I am using Twilio Adapter to connect to a bot designed using Bot composer. The bot works well in other channels, including Telegram, Web and DirectLine but WhatsApp. I need to make it work on WA. Can someone help?

Here are the steps to repro:

  1. In Bot Composer - project settings - include custom runtime
  2. added a new controller for twilio (followed the instructions given here)
  3. deployed the bot to Azure App Service
  4. Updated the App Service configuration with twilio information (account SID, auth token, from Number and validation URL)
  5. Registered Twilio channel in the Bot Channel Registration
  6. Update Twilio WhatsApp Sender profile to add a webhook (pointing to https://mybotapp/api/twilio)

Now when I test the bot in the Web chat, it works properly. However when I try it on Twilio side using WhatsApp, I am getting a 500 Error

Appreciate if someone can help

Originally posted by @hsachinraj in https://github.com/microsoft/botbuilder-dotnet/issues/5094#issuecomment-764504802

stevkan commented 3 years ago

@hsachinraj, using a service adapter (like the Twilio WhatsApp one) means you are choosing to have your bot communicate with the service directly. As such, you do not need the Twilio channel to be enabled in your Bot Channel Registration. The same is true for the reverse. If you intend to use the channel connector in your Bot Channel Registration, then you do not need the adapter. Please select and configure the one you intend to use, try again, and let me know if you still receive an error. While I don't put too much stock in this, it's possible the two are conflicting.

hsachinraj commented 3 years ago

Thanks @stevkan. I have tried removing the channel connector yet I still get the same response - Internal Server Error 500 :(

  1. In this doc, I see the following line needs to be added to startup.cs services.AddTransient<IBot, EchoBot>(); Since I am using composer to generate the Bot, I don't see any Bot class created under the runtime folder. So, I don't know what should I pass as parameter here.

  2. Secondly, this repo also seems to be supporting only SMS scenario and not WhatsApp messaging - is that correct?

stevkan commented 3 years ago

@hsachinraj, Yes, that is precisely the problem. Both the Twilio bot registration channel and the dotnet SDK's Twilio adapter only support Twilio and do not extend to WhatsApp. Unfortunately, while there have been discussions around extending to WhatsApp, there is no active development at this time.

Of note, while there is a Twilio-WhatsApp adapter available in the BotBuilder-Community JS repo, a matching one does not exist for dotnet. However, there is an Infobip-WhatsApp adapter that you may be able utilize as a workaround. As stated in the ReadMe.md file:

Incoming WhatsApp message requests are transformed, by the adapter, into Bot Framework Activites and then when your bot sends outgoing activities, the adapter transforms the outgoing Activity into an Infobip OMNI failover messages.

Lastly, I apologize for any confusion I may have created. Initially, I mixed up in my head the community adapters with the official thinking the Twilio-WhatsApp adapter existed in both repos and were official, not community.