One Way WhatsApp Messaging Using Twilio and Power Automate
    • Dark
      Light
    • PDF

    One Way WhatsApp Messaging Using Twilio and Power Automate

    • Dark
      Light
    • PDF

    Article Summary

    #ServerlessTips - Power Automate
    Author: Kent Weare Integration MVP

    WhatsApp is a popular messaging service owned by Facebook that has more than 1.6 Billion users. As a result, it becomes a highly sought after messaging channel for chatbot and automated solutions. As of this writing, there is no out-of-box connector available for WhatsApp and Power Automate. However, Twilio provides a messaging API that allows us to make WhatsApp calls from Power Automate.

    Note: WhatsApp has very specific requirements on their APIs. Please review their Business Policy here.

    In this post we will provide a brief walkthrough of how we can call the Twilio API from Power Automate. To see a video walkthrough, please watch this YouTube video.

    1. For the purposes of this post, I am using a trial account from Twilio. As part of my trial account, I am provided with an Account SID which I need to copy as I will require it when making API Calls. After making a note of your Account SID, click on the Get Started tutorial.
      1-Account

    2. Click on Programmable Messaging – Try it Out – Try WhatsApp. We will now work our way through a wizard to create a sandbox that we can use to test the APIs. To complete the wizard, we need to have an existing WhatsApp account and need to add a Twilio phone number to our contacts. We subsequently need to send a code to enroll in the process.
      2-setup

    3. Once we have sent the code to the Twilio contact, we will receive an acknowledgement in our WhatsApp client and we will see a Message Received! Confirmation on the Twilio website.
      3-setupcomplete

    4. We can now continue in the wizard to explore One-Way Messaging. Out of the box there are three templated scenarios that we must use:
      a. Appointment Reminders
      b. Order Notifications
      c. Verification codes

    Explore these different scenarios using their test harness. You will see messages appear in your WhatsApp device. For my purposes I am using the WhatsApp application for Windows 10 but notifications also appear on my phone.

    Also pay attention to the sample curl code that is being used by the test harness. This provides us with some key insights on how we will make an HTTP call in Power Automate.
    4-test(1)

    Note: There are also sample Two-way messaging scenarios which we will explore in a future post.

    1. We can now configure an HTTP call inside of Power Automate with the following values. For many of these values we can copy from our CURL sample in our previous step. However, there are a few important considerations:

    a. The To: and From: WhatsApp numbers must use their convention of: To=whatsapp:+15555551212 and From:whatsapp:+15555551212
    b. Since we are using form url encoding as our Content-Type, we need to ensure the values included in our POST call are all encoded using the encodeUriComponent expression. Only encode the values as illustrated in following image.
    c. We will use Basic Auth. We can retrieve our username, which happens to be our Account SID, and secret from the curl sample.
    Picture1(16)

    Testing

    When we run our flow, we will receive our message in WhatsApp.
    Picture2(15)

    Conclusion

    In this post we walked through how we can call WhatsApp from Power Automate by using the Twilio messaging API. This unlocks even more notification opportunities inside of Power Automate.


    Was this article helpful?