Create a WhatsApp QnA Maker Bot using Power Automate and Twilio [Part 1]

In this blog series, we will create a WhatsApp Bot that will connect to QnA Maker using Power Automate and Twilio. This will eliminate the usage of cloud functions such as Azure Functions.

In this part, we will create the initial flow in Power Automate and also set up the Sandbox environment in Twilio for WhatsApp.

Prerequisites

  1. Twilio Account
  2. Microsoft Flow Account

Create Power Automate Flow

Here, we will create an HTTP trigger flow that will get triggered when a new WhatsApp message is received. Click on New flow and choose Automated cloud flow.

Click on Skip for now, we will add the trigger in Flow designer.

Search for When an HTTP request is received and click on it. If clicking on any PREMIUM connector, asks for Start Free Trial, do it.

Let us add the sample schema for now. Later, when we run the flow, we will get the exact response that can be used to generate the schema. Click on Use sample payload to generate schema.

I have given the simple JSON sample. Click on Done.

This will generate a test schema for us.

Click on New Step and Add the Response action.

Switch the Header to text mode.

Add Headers from the Dynamic Content. Also, add sample response in the body.

When you save the flow, the HTTP POST URL will be generated in the trigger. Copy this and save it for future use.

If you notice above, we have not used QnA Maker anywhere. We will add it later when we get the exact schema.

Setup WhatsApp Sandbox Environment in Twilio

From the Twilio Console, click on All Products and Services.

Click on Programmable Messaging.

Click on Try it Out.

Click on Try WhatsApp and follow along with a small tutorial provided by Twilio to set up the Testing Sandbox for WhatsApp.

When you reach the final page of Configure Sandbox, paste the HTTP POST URL we copied from the Power Automate in WHEN A MESSAGE COMES IN. Scroll down the page and click on Save.

Getting the Sample Payload for Schema

Send a message on WhatsApp. You will get an error on your Debugger Console in Twilio. Click on it and select Go to Debugger.

Open the latest event.

Scroll down to the bottom and see the Body in the response. This is the same response body we created in the Power Automate. This verifies that our Power Automate flow has triggered and run successfully.

Check your Power Automate flow Run History and open the flow output by clicking on the time stamp.

Open the trigger and click on Show raw outputs.

Here you will find all the details including the message you sent and from which number you sent the message. I had sent jd bot in WhatsApp and here it is shown.

With this JSON request received by Power Automate, we will be able to create the Schema. See you in the next part for continuing the build of the Power Automate flow.

Thank you All!!! Hope you find this useful.

If you liked our content and it was helpful, you can buy us a coffee or a pizza. Thank you so much.


Up ↑

%d bloggers like this: