Deconstructing Chatbot: Integrate Dialogflow with Twilio Messaging Service
In this article we will learn how Dialogflow integrates with Twilio messaging service for SMS which allows to easily create Twilio bots with natural language understanding. Programmable SMS service from Twilio makes sending and receiving SMS easily. If you are following the Deconstructing chatbots series, we will use the same Agent that we created in previous labs “Appointment Scheduler”. Although you can use any Dialoglfow agent and work through this article to create the integration. We will finally test to see if the integration by sending the requests over chat.
What you’ll learn
- How to enable Twilio integration from Dialogflow
- How to test the Dialogflow bot with Twilio integration
- Basic concepts and constructs of Dialogflow. For introductory Dialogflow tutorial videos that covers basic conversational design check out the Deconstructing chatbot series.
- We will be using the same Appointment Scheduler chatbot that we built in this article.
- Also go through the “Deconstructing Chatbots: Integrate Dialogflow with Twilio Messaging Service” youtube video for more instructions on setting up this integration.
Enable Twilio integration from Dialogflow
We will use the same appointment scheduler chatbot that we build in the previous codelab and work through the integration.
- Navigate to the Dialogflow Console.
- Select the AppointmentScheduler agent that we created previously.
- Click on Integrations and then click on “Twilio (Text messaging)” integration settings.
- The pop up has instructions: Click on start, Copy the request URL and put it in Twilio Programmable SMS.
- The first thing you will need is a Twilio account, if you don’t have one create it and log in.
- From the dashboard, click on all products and navigate to Programmable SMS.
- Once you are on the programmable SMS dashboard, click on SMS
- If you already have an appointment scheduler messaging service set up, use that, if not, you can just create one. Provide a name, in the use case, select Chatbot/interactive 2 way.
- Click on the created messaging service to assign a phone number.
- Use the add button to buy a new number or use an existing number.
- Click through the US selections and you should have a number assigned.
- At this point, we click on configure to integrate Dialogflow.
- Enable Inbound settings
- In the Request URL copy and paste the URL generated by Dialogflow in the integration section and save.
- Copy Service ID, Phone number and AuthToken from the Twilio dashboard and paste them in the Dialogflow integration console. Once you are done click on start.
You will notice that the bot has started successfully.
Test the Agent
In order to test the agent and Twilio integration use text messaging on a phone. Send text message to the number that was assigned to the Twilio messaging service and run through the example appropriate for your agent.
For the appointment scheduler agent, this is the test you can try:
You enabled a Dialoglfow agent for text messages by using Twilio Messaging service!