WhatsApp by Twilio
This node.js example connector allows you to make your Teneo bot available on WhatsApp using the Twilio API for WhatsApp. This guide will take you through the steps of setting up a Twilio WhatsApp sandbox phone number and deploying the connector so it can respond to messages sent using WhatsApp.
You can find the source code for this connector on Github.
Making the connector available via https is preferred. Ngrok is recommended for this.
Your bot needs to be published and you need to know the engine url.
- Download or clone the connector source code:
git clone https://github.com/artificialsolutions/tie-api-example-twilio-whatsapp.git
- Install dependencies by running the following command in the folder where you stored the source:
- Start the connector with the following command (replacing the environment variable with the appropriate value):
TENEO_ENGINE_URL=<your_engine_url> node server.js
You can make your locally running connector available via https using ngrok as follows:
- The connector runs on port 4337 by default, so execute the following command:
ngrok http 4337
- Running the command above will display a public https URL, copy it, we will use it in the following steps.
Setup a free Twilio account, which comes with free credit money you can spend on buying a number.
Go to the left panel menu and click the Programmable Messaging item, then from the submenu choose Try it Out > Try Whatsapp.
Follow the 5-step process to setup communication between Twilio Sandbox and WhatsApp on your phone.
Next, in Programmable Messaging > Settings > Whatsapp Sandbox Settings submenu, add the https URL you copied earlier to the When a message comes in field. Hit save at the bottom of the page.
That's it! Now you can use WhatsApp to interact with your bot!
The Twilio API for Whatsapp is currently in beta. For more details, visit the Twilio website: Twilio API for WhatsApp.