DialogFlow
Build a Dialogflow-WhatsApp Chatbot
Last updated
Was this helpful?
Build a Dialogflow-WhatsApp Chatbot
Last updated
Was this helpful?
There are times where the use of Natural Language Processing (NLP) can positively impact the customer experience. One such channel is the world's most popular messaging app, WhatsApp. Therefore, this article will show you how to build a chatbot using Googleโs NLP software Dialogflow in combination with our WhatsApp API.
First and foremost, you need to create your Dialogflow agent. In short, โagentโ is Dialogflow is, essentially, the bot you are building. We have to start here:
Next, create the name, pick the time zone and language for your agent. Select your Google Project. It's required. This ID will be used later.
Its main building components are intents which help the agent identify what the user actually wants to do.
Each intent requires training phrases (all the different ways a user can ask for the same thing) and, of course, the responses (always create more variations to keep repeat conversations natural.
When all that is set up, go to the intents section using the menu on the left and start creating the intents.
Create phrases (as many as you can) that users will write to you:
Prepare the answers (preferably a variety of them) that the bot will use in its response:
Connect any number to Whapi.Cloud.
Go to your personal cabinet of Whapi.Cloud to the Integrations section and select DialogFlow there.
Get the token by granting permission to our app to process your bot in DialogFlow.
Use the API documentation to work with DialogFlow.
Warning, this is not a chatbot builder. This is an integration built for developers!
You receive an incoming message from the client via our webhook.
You forward the message to DialogFlow through a special API request.
DialogFlow generates a reply based on the conversation context.
You take the botโs reply and send it back to the client using our API.
In other words, DialogFlow only generates the reply โ you are fully responsible for delivering the message to the customer via your WhatsApp API channel.
Key points to set up:
Thus, you must build your own lightweight forwarding logic to manage the flow between the client, DialogFlow, and WhatsApp.
POST https://tools.whapi.cloud/integrations/google_dialog_flow/send
The request will require specifying a Header with the name Authorization and the value "Bearer {your_channel_token}"
Body:
You can pass any value to the โsessionโ
parameter, but it makes the most sense to use the phone number of the person you are chatting with. This parameter is necessary to preserve the context in the conversation.
In response you will receive a result generated by DialogFlow, use it to send a message from the bot to your clients!
Enable and configure a webhook to receive client messages: ;
Use the DialogFlow integration endpoint to send incoming messages and get the botโs reply: ;
Forward the bot's response back to the client using our sending methods: ;