How to Create a Chatbot with Dialogflow, NodeJS, and Webhook
Build an example chatbot that process Dialogflow request and send a response from the server.
3 min readMay 13, 2021
In this tutorial, we are going to learn how we can make a chitchat bot using Dialogflow using webhooks and NodeJS
What is Dialogflow
- Dialogflow is a natural language understanding platform that makes it easy to design and integrate a conversational user interface into your mobile app, web application, device, bot, interactive voice response system, and so on.
- Using Dialogflow, you can provide new and engaging ways for users to interact with your product.
What are webhooks, exactly?
- A webhook is a simple HTTP callback that gets triggered base on some events
- event is defined by the users, for example, publishing a comment to blog post, or publishing a new tweet on your Twitter app.
- when a webhook request received a webhook request contain user speciation data.
Steps to create and integrate Dialogflow agent with NodeJS
Create an Agent
- An agent is just a chatbot you can train the agent with the training phase and their corresponding response to handle expected conversion scenarios with your end-users
- go to https://dialogflow.cloud.google.com/ and login with your Google account
- you can see the next screen like this
- now we need to create intent with some training phase let’s create intent
- here I create intent which name is get_user_informaction and I added few training phases. when intent trigger webhook call and get user information from backend which is a database or any other source
- Now let’s setup node JS server
STEP TO SETUP NODE JS SERVER
- create a new folder on your anywhere in your system
- Download & install nodeJs click here for download
- I already make one small node JS server and the code is pushed into GitLab you can see the code inside code I will add comments and explain all lines one by one so just download the code and you can use it
- GitLab :- https://gitlab.com/msb6531/dialogflow-webhook
- now we need to set URL into Dialogflow so Dialogflow send request Dialogflow only allow HTTPS URL so we use ngrok you can download from `https://ngrok.com/download`
- now the last setup we need to enable Fulfillment for intent and click on save
- I also write one doc file for you guys so you can see how it’s work
- word document link
Thanks for reading this article! Leave a comment below if you have any questions 😊.