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.
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.
When an HTTP request is received and click on it. If clicking on any PREMIUM connector, asks for Start Free Trial, do it.
Request Body JSON Schema blank.
Click on New Step and Add the
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 WhatsApp Message details.
Setup WhatsApp Sandbox Environment in Twilio
From the Twilio Console, click on All Products and Services.
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
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 get all the metadata details. 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.