DEV Community

nescampos
nescampos

Posted on

Integrating Twilio for Whatsapp and Azure bots (LUIS)

What I built

Category Submission: Interesting Integrations (Twilio for Whatsapp with Azure Cognitive Service, LUIS)

I built a library (a class called TwilioAzCognitiveIntegrator) in C# for using LUIS (the Azure service for Language Understanding

Why? Because I had a chatbot build with Azure Bot Framework, and I have to evaluate if my bot can work with whatsapp. But in Azure Bot Service, the only channel with Twilio is SMS, so I had to create a new solution for that

Demo Link

The demo works with Twilio for whatapp.
In your account, you can configure the webhook in whatsapp sandbox with this URL: https://demotwilioluis.azurewebsites.net/message/index

Demo in sandbox

Link to Code

The code is in my github repo: https://github.com/nescampos/twilioluisdemo

How I built it

To do this, and considering that my bot used LUIS to interpret the questions (and give me a score for the user's question, to know if it was a normal or negative comment), I built a class that calls the API of this service simulating the Same use of Bot Framework, and depending on the score of the question (positive or negative) I can have different answers for the user (the answers are saved by database, but for this demo, they are in a JSON file in the project).

Responses JSON file

Then, using C#, I created this API call in combination with the Twilio library for C#, in order to generate the answers to the detected question / intention.

C# library

Finally, I created a web application with ASP.NET MVC that calls my new class (with the parameters in the web.config file for LUIS app keys) to return the response using Twilio Webhook.

Hope you enjoyed it, I am able for helping you with my experience #twiliohackaton

Additional Resources/Info

If you want to understand more about LUIS (if you implement Azure Bots and you want to connect with Twilio for Whatsapp): https://docs.microsoft.com/en-us/azure/cognitive-services/LUIS/luis-get-started-get-intent-from-rest?pivots=programming-language-csharp

Top comments (1)

Collapse
 
amsmart profile image
Emmanuel Oluwagbemiga Adebiyi (Smart)

Nice one!