top of page

How To Create Chatbot Using Dialogflow?

Updated: Mar 19, 2021

In this Blog, we will learn how to create a chatbot using Dialogflow. Before start it first we learn, what is Dialogflow and why we will create this project?


Topic, which we will learn and cover in this Blog:

  • What is dialogflow?

  • Introduction About enterprise edition.

  • How to create an agent in dialogflow?

  • What is intent and entities in dialogflow?

  • Creating Diglogflow project.

  • References.


What is Dialogflow?


Dialogflow is an end-to-end development suite for building conversational interfaces for websites, mobile applications, popular messaging platforms, and IoT devices. It can be used to build chatbots, voice assistants etc especially relevant that are capable of having natural and rich interactions with your users.


Introduction About Enterprise Edition


Dialogflow Enterprise Edition is available as part of the Google Cloud Platform (GCP). Dialogflow Enterprise Edition is a premium offering, available as a pay-as-you-go service.


How to create an agent in dialogflow?


Step 1:


First go to the dialogflow official link:



After this sign in and then click on Go to console, as per given below screenshot.



Now new window is open like this:




To start new project click on dropdown symbol which is near to setting icon, which in on right corner and then click on create new agent.





Agent is created, my agent name is DFDatabaseDemo, which we creaed in this project.


Now we create an intent by click on plus(+) icon, my intent name is save to db, you can create as per your choice. After enter intent(save to db) click on Create Intent. Intent(save to db) is created and new window is open.




After entering intent name SaveToDB click on save button and then create training phrases like: save my data, save to db, save to database, etc.


And after this add Action and parameters which is below part of this. Scroll Down and create this:


Enter Parameter name, entity, value and set prompts like: Which would you want to save? and many.




After This enable fulfillment which is below part of this.




Now Simple chatbot format is created, if you want to add data in database then add code in fulfillment section.



Save and fetch data from google Firebase:


To do this, first add code line in fulfillment section like this, which we enter in our project.

First click on fullment section:




Add this code:





After this Deploy, then firebase database link( View execution logs in the Firebase console) is generated click on this and go to the realtime Firebase Database.




Sometimes this types error face after click on this link:




To solve this modify the URL


Demo URL but not active try own URL


https://console.firebase.google.com/u/0/project/dfdatabasedemo-fwyxku/functions/logs


After modify:

add 0 or 1 or 3, etc


https://console.firebase.google.com/u/1/project/dfdatabasedemo-fwyxku/functions/logs


then it work and new window open.




After clicking Realtime Database New window open:




Create reference field data, Please remember this is same as fullment ref function data for ex.


function handleSaveToDB(agent){

const text = agent.parameters.text;

return admin.database().ref('data').set({

first_name: 'Sachin',

last_name: 'kumar',

text: text

});


And then create other field inside it like, first name, last_name and text.

Here we update text field as per firebase database. and first_name and last_name as a default you can change it by code section.


Now project is ready we run it:


now back to the dialogflow and enter


save to db in right side box and then enter, then it asked, what would you want to save?

you can enter anything then database text field updated you can see it by going to database tab.




First enter save to db and enter

Second enter Ram

Now database field updated you can check it by going to the realtime database.




If you like Codersarts blog and looking for Assignment help,Project help, Programming tutors help and suggestion  you can send mail at contact@codersarts.com.

Please write your suggestion in comment section below if you find anything incorrect in this blog post.


Comentários


bottom of page