WhatsApp Messaging Using Twilio

Published in
4 min readAug 17, 2021

--

In this blog I will show you how to connect your business with the most popular chat app globally. For medium & large-scale businesses, the WhatsApp business API powers your communication with customers all over the world, so you can connect with them on WhatsApp in a simple, reliable & secure way. Send your customers the information they are expecting where they want to receive it.

To integrate to WhatsApp’s business API, the first step is to get access to the WhatsApp business API, which you can get through a WhatsApp Business Service Providers (BSPs).

There are different business API’s which integrate with WhatsApp, I will try to integrate using Twilio’s service. We can build WhatsApp messaging quickly and easily in the Mendix platform with Twilio’s Programmable Messaging API. Integrate a single API to reliably send and receive WhatsApp messages.

The main dependency for this integration is the TwilioConnector module in Mendix, which is already available in Mendix marketplace

After downloading the module into your project, expand the TwilioConnector module in Studio Pro-> Expand Encryption -> Consts. In the EncryptionKey constant, add a 16-character string. Make sure it’s 16 characters.

This is the key that will encrypt your Twilio API key.

Next go to twilio.com (https://www.twilio.com/) and sign up for an account, if you don’t have a Twilio account is setup already.

1. Make sure to copy Account SID and Auth Token from Twilio dashboard.

2. Now click on Three dots, on left hand side of Twilio navigation -> Then choose Phone Numbers -> Verified Caller IDs -> Click on Plus icon -> Choose the desired country & enter mobile number for verification

NOTE: Make sure whatever contact number you are trying to use should be the active WhatsApp number

3. Now click on Three dots, on left hand side of Twilio navigation -> Then choose Programmable Messaging -> Try it Out -> Try WhatsApp -> Save the WhatsApp number which Twilio has provided and note down the Twilio Sandbox command. (You should find this command under 1. Set Up your Testing Sandbox)

And this command needs to be sent to Twilio WhatsApp chat once for every 24 hours.

https://www.mendix.com/pricing/

4. Open SendSMS microflow from Twilio Module:

Open Rest call activity, and update the Request Template accordingly.

SendSMS Microflow

Now map the TestSMS & Credential_Overview pages from TwilioConnector module in the navigation menu and run the application.

5. Configure the credentials.

6. Switch to the TestSMS page and send a test message by entering the reference to the credential, enter the destination number (Which you verified in step:2)

Use the plus sign for the destination number, yup that means for Indians: +918887654345, to Americans! Example: +15551212 for USA, +314444444 for NL etc. and type some message.

7. Click the Send button. If the configured data in step: 5 & 6 are valid, then you should receive Message to your verified WhatsApp number.

Using Twilio Phone Numbers with WhatsApp:

To use WhatsApp messaging in production apps, you must enable WhatsApp on your Twilio number. WhatsApp is currently opening this access in a limited availability program. This means that WhatsApp approval is required for all customers who wish to create their own profiles.

I hope you found this blog useful & interesting!

Read More

Twillio’s documentation:

Twilio WhatsApp API:

Sandbox activations steps in Twilio:

From the Publisher -

If you enjoyed this article you can find more like it at our Medium page or at our own Community blog site.

For the makers looking to get started, you can sign up for a free account, and get instant access to learning with our Academy.

Interested in getting more involved with our community? You can join us in our Slack community channel or for those who want to be more involved, look into joining one of our Meet ups.

--

--