How to Integrate Twilio with Botpress, Step-by-Step
Many thanks to a Botpress community contributor, Danilo Limo! We're happy to share here his recent how-to, posted in the Botpress community forum. He created a step-by-step tutorial on how to integrate Botpress with Twilio, using Whatsapp and working on his Windows machine. We really appreciate our community, and would love to share any tips, tutorials, or other content devs create with Botpress!
Integration Tutorial
Step-by-step
This tutorial aims to demonstrate how the botpress framework is integrated with Whatsapp through the Twilio platform.
Note: For ease I will describe the step-by-step for Windows since it is the environment I am currently using.
Prerequisites:
To use Twilio as integration of your botpress with Whatsapp it is necessary that your bot has external access via SSL /TLS [ https ]
If your bot is being built in a local environment(localhost) you will need to use a tunnel application such as NGROK so that you can access your localhost externally.
Follow the steps below:
- Download NGROK in ngrok - download
- Unzip the file and rotate the executable
- In the /ngrok/bin folder run the ngrok file.exe
- The command prompt [cmd] will open
- In it run the following command: ngrok http 3000, where ngrok is the executable command of the application, http indicates that it will be accessed via web and 3000 is the default port of Botpress
If you are developing your bot in cloud environment, such as Heroku for example, just use the external url of your bot which should look something like this: https://<yourbotname>.herokuapp.com/
Twilio
Now let’s go to Twilio!!
- Create an account on Twilio (I will not describe here how to create an account in Twilio because it is very simple and intuitive to create an account).
- When you create the account, in your account dashboard, copy and reserve the keys: accountSID and authToken.
Register your phone number in your account, as Twilio will need it.
Once that’s done, now it’s time to set up your Twilio access credentials in Botpress.
Botpress
In Botpress you perform the following steps:
- Open the \data\bots<your_bot>\bot.config.json file
- Include, before the last “}”, the json code block as below:
"messaging": {
"channels": {
"twilio": {
"enabled": false, "change here to true"
"accountSID": "Enter your key accountSID here",
"authToken": "Enter your key authToken here"
}
}
}
It should look like this:
3. Go to \data\global\ folder and open the file botpress.config.json
4. With the file open, change the parameter externalUrl as follows:
"externalUrl": "https://6a3d-a700.ngrok.io",
"session": {
"enabled": true, “If false change to true”
"maxAge": "1h"
},
It should look like this:
- 5. Now, in the \data\global\config folder, open the channel-twilio.json file and configure it as follows:
{
"$schema": "bp://types/modules/channel-twilio/config.schema.json",
"enabled": true,
"accountSID": " Enter your key accountSID here",
"authToken": " Enter your key authToken here"
}
It should look like this:
6. Now copy the channel-twilio.json file from the \data\global\config folder and paste it into the \data\bots\ folder <your_bot>\config
7. Once that's done, it’s time to restart your Botpress. Once you restart, you should see the initiation log the URL of the Twilio webhook in Botpress. You must present as:
8. Now copy the Twilio webhook url, go to your Twilio account, and paste it into the webhook section, as shown in the image below:
- 9. Now, while still in your Twilio account, go to menu Messaging → Try it out → Send a Whatsapp message
- 10. You will need to activate Twilio Whatsapp, so open Whatsapp as follows:
- 11. This “join lot-idea” code activates Twilio to interact with your Botpress.
- 12. If you want to disable the Twilio service just send a message with the text “stop”.
- 13. And that’s it! Your Botpress is prepared to send and receive messages by WhatsApp. See the interaction of messages, as well as the log:
And that's it!
Many thanks to Danilo! You can see his fine original post in the Botpress forum. If you're interested in more Botpress how-to's, check out the Botpress YouTube channel, where we've been adding lots of new developer content over the past few months.
In fact, there is a just-published how-to video on the Botpress Twilio Channel Integration, with up-to-date review of how to use Twilio with Botpress. Check it out!
Share this on:
Build your own personalized AI chatbot for free
Get started building a personalized GPT bot with our intuitive drag & drop interface.
Get started – it's free! 🤖No credit card required
Stay up to date with the latest on AI chatbots