Example for connecting Twilio with LUIS (luis.ai) and using in Twilio for Whatsapp.
This is a demo connecting LUIS.ai with Twilio for using Whatsapp, because there is no native connection between Azure Bot Framework/Service and Twilio for Whatsapp. In this project, I extracted the necessary components to connect the Azure Language Understanding (LUIS) to use as a service and connect to Twilio using Webhook. This project will be useful for all developers who have a chatbot developed with Bot Framework and need to use it with the WhatsApp channel with Twilio. The implementation is with .NET Framework 4.6.1 and ASP.NET MVC and Twilio libraries from NuGET.
This application works when you publish the Web application in a web server with public access.
- A library project (TwilioAzureCognitiveServices) with all classes for using in your project and connect the tools.
- A Web project for testing the library project and connect the services.
- LUIS.ai account
- A Twilio account - sign up
- Create an application in LUIS and train your model with intents, publish your luis app with sentiment analysis enabled in production slot.
- Open the solution (.sln) in Visual Studio
- Edit the file data\responses.json with your intents and their responses in NormalFeelingResponse field and NegativeFeelingResponse field (if you want your whatsapp bot have a response for negative questions).
- Edit the web.config in web app (TwilioAzureCognitiveServices.WebTest), you must upload the LUISUrl key with your luis app region endpoint (for example: eastus.api.cognitive.microsoft.com), LUISAppId and LUISAppKey with your app data.
- Build the web app (TwilioAzureCognitiveServices.WebTest). It's possible some libraries to be downloaded by Nuget.
- Publish your web app in a public web server or cloud (Azure, AWS EC2, etc.)
- Get the url of your app.
- Add to the url of your app the following at end: /whatsapp/index
- Copy your final URL (where your webservice is published) and paste it in your whatsapp sandbox (webhook message).
You must have a Web server with support to .NET Framework version 4.6. It doesn't work locally because when you need the final URL and update your whatsapp sandbox in Twilio account.
This template is open source and welcomes contributions.
No warranty expressed or implied. Software is as is.