How To Article

How To Build a Chatbot with Dialogflow – Dialogflow Tutorial

By February 10, 2019 August 1st, 2019 No Comments
How To Build a Chatbot with Dialogflow - Dialogflow Tutorial

Follow along this video 3-part series and watch how a fictional small business owner learn how to build a Dialogflow agent, deploy it, and add features you can't get on Dialogflow alone. This Dialogflow Tutorial will help you get started on your journey. If you prefer a written text over videos please check out our article about Using Rocketbots as a Dialogflow CRM.

Takeaways

By the end of this 15 minutes tutorial, you will be able to:

Part 1:

  • Understand how Dialogflow (and other NLP engines) work
  • Properly create and modify intents
  • Identify your most urgent questions
  • Connect Dialogflow to many messaging channels at once

Part 2:

  • Create a Welcome Intent & Fallback Intent
  • Identify the queries that your bot can't answer
  • Pass (handoff) the conversation to a human if the Dialogflow fails
  • Send Email notification when the Dialogflow agent fails

Part 3:

  • Hot to train and improve your DF agent
  • How to send broadcast and updates to your DF users
  • Build an automatic tag capturing agent

Dialogflow Tutorial Part 1: Building a Basic Dialogflow Agent

Build a Basic Chatbot and Deploy It to Facebook Messenger

What’s a Chatbot?

A chatbot is an Artificial Intelligence powered program that can answer questions automatically. Some of the popular messaging apps that you might already know include Facebook Messenger and WeChat. The main purpose is to engage customers and collect valuable information.

Wait, Why Do I Need a Chatbot?

Most customer inquiries that you receive are essentially asking about the same kind of questions: do you open on the weekends, what sort of products do you sell, and etc. They are mostly questions that can be easily answered, but the repetitiveness and volume of these questions still mean it’s time out of your (or your staff’s) day to address them. Follow the Rocketbots Chatbot Academy and we’ll show you how you can automate responses and more.

Planning the Purpose of Chatbot

1 Collect inquiries and FAQs: Collect the most frequently asked questions. The questions are also called expressions in chatbot development. Basically, expressions represent a user’s desire or aim.

2 Group the intentions: Group the questions into their corresponding intentions. This is to group the expressions by the aim the user has so as to get a more clean and organized set of categories to handle. Sort them by the most common intents, such as opening hours, products, and location for the chatbot to tackle.

3 Provide responses: Provide a response that satisfies each intent.

Building Chatbot on DialogFlow

1. Create an Account: Go to a free chatbot building tool like DialogFlow and make an account.

2. Create an agent: Go to the dashboard, and click “Add Agent” at the top left. Give the agent a name and make sure the agent is in the right language and time zone. Then click “Create”.

3. Create intentions: Create the first intention by clicking “create intent” at the top right, and give it the name “Opening Hours”. Proceed by clicking “Add Training Phrases” and input the expressions you’ve seen customers ask before, and any other expressions you think a user might say to get the same answer. It’s best practice to use a minimum of 20 expressions.

4. Create responses: Click “add response” by scrolling down the page. Then add the store business hours or other corresponding response to your intent. Save the intent at the top right, and repeat the process for each of the other 2 intents.

Now the chatbot is at its most basic level, and ready for deployment on Facebook.

Deploying Chatbot on Facebook Messenger

1. Connect a Channel to Rocketbots: Go to the Rocketbots Platform settings. Click on the "Add Channel" button under Channel Settings, and add Facebook as a Channel.

2. Connect Dialogflow to Rocketbots: Go to Rocketbots Platform settings. Under Integrations you will see Dialogflow as one of the option. Follow the instructions shown there.

Dialogflow Tutorial Part 2: Adding Human-Handoff and Notifications to your Chatbot

Learn how to take over the conversation from a chatbot to a human

Default Welcome Intent

You may already notice whenever you use a chatbot, there’s always a greeting like “Hello” pops up right on the second you click on the chat box. But, this is actually the default welcome intent that naturally comes with the agents itself that you don’t have to input yourself. Facebook automatically adds the “Get Started” button to any chatbot that gets deployed on Messenger. As there’s no need for one when the bot is greeting the user for the first time, there are no training phrases inside the default welcome intent.

Guiding Your Users

1. Delete these default responses: Replace them with 3 of our own such as the example as shown below. 

2. Set the first response: as “Hello!”,  followed by “I am a chatbot to help answer questions about xxx” and finally “I’m still learning, so try to keep things simple for me!”

This can also let the user know what the purpose of the chatbot is, it’s less likely the user will ask it topics that it doesn’t know.

When the bot is being asked questions that it doesn’t know how to answer, then it will automatically revert it back to back to the Default Fallback Intent. And here’s how you can adjust the fallback intent response. 

Setting the Bot to Allow Human Handover

1. Edit the response: Editing the response module of the Default Fallback Intent.

2. Change your expression: Change it to “I’m sorry, I haven’t learned how to answer your question. Would you like me to get the human agent to come to help you?”  This would give users a chance to contact the human agent. 

3. Input your expressions: Input at least 20 expressions in the training phrases module that the user might say to let the bot know they’re interested in having the human agents to cut in and help.

Adding in the Notification

1. Add the parameters to the intent: Add a code that marks the chatbot as “not done” on the Rocketbots platform, which would allow the human agent to know when users are pending for assistance on the platform.

2. Input the values: Type: RB_MARKDONE and set the value as false. 

3.  Enter the code: Input another code that’s going to allow the Rocketbots Platform to notify the human agent when she/he’s been requested to help a user. Type: RB_NOTIFY, and set the value as @user.name needs your help

Checking Your Bot

1. Delete the conversation; Delete the chatbot conversation from Facebook Messenger, and start over again.

2. Check the default welcome intent: Now see if the new default welcome intent is working or not by asking the bot a question that it doesn’t know how to answer.

3. Getting the request: A request with the option to contact the human agent will pop up on the screen. Click on it. Then, it would send the human agent a notification on the platform, and via email that we’re looking for help. Check on your side to see if that’s the case.

Now you can have an improved chatbot that would lessen the number of errors it can encounter, and a backup strategy that lets the human agents jump in when the bot can no longer answer questions.

Congratulations! Now you know how to switch your bot for human agent takeover.

Dialogflow Tutorial Part 3: Improving your Chatbot and Broadcasting messages

Improving your Chatbot Experience with Training and Broadcasts

In this final section, you’ll get to learn how to train the chatbot and broadcast through it. The chatbot that you’ve built in the last two tutorials might can get you to answer customers’ inquiries fast; but there’s one problem – you still haven’t give it the ability to deal with the bot when it comes across questions that it doesn’t know how to answer at all or when the bot give out the wrong response. And the following will show you how to deal with situations like that.

How To Train Your Chatbot

1. Click on the training option to the left: In this menu, there are rows of data. Each row is a single conversation.

2. Click a conversation. You’ll be brought to the sessions window. This is where you’ll train your chatbot. Each line you see here is a single request and the corresponding intent that it triggered.

3. Mismatches: If you see a request that matches the correct intent, don’t do anything. If a request is assigned to the incorrect intent, click the intent below, and search for the right one to assign. If the request was not assigned to any intents, you can click “click to assign” below, and assign it to the correct intent.

4. Double check your corrections before you click approve. As assigning a request to the wrong intent, or approving a mismatched request can cause your chatbot to learn how to make that mistake more often.  

5. Click Approve. Give the chatbot agent some time to learn how to train.

Create A New Intent To Solve Another Customer Inquiry

1. Start by creating an intent. Use the same best practices as before.

2.  Create at least 20 requests asking about the topic of Fruit Delivery. Set the response as “We get fresh fruit delivered at sporadic times from different orchards and farms in the region, so we’ll let you know when there’s a delivery coming as soon as we know ourselves!”

3. Add a parameter to this intent. This can tag users who inquire about fruit deliveries. Click on Add Parameter, and type “RB_ADDTAGS”, and set the value as Fruit Delivery. Remember to save the intent.

From now on, when a user asks the chatbot about fruit deliveries, they will be tagged in the Rocketbots Platform with the tag “Fruit Delivery”. You can now use the Broadcast feature on the Rocketbots Platform to update her curious users with updates on deliveries as soon as she knows.

Broadcasting the Updates

1.  Click on Broadcasts to the left on the Rocketbots Platform.

2. Select New Broadcast at the top right. Here you’ll be able to write your broadcast message

3. Select your channel or channels you’d like to broadcast to. Choose the tag you want to target in your broadcast.

4. Write your delivery update Select Facebook as our channel, and then select the Fruit Delivery tag to target any users who have inquired about delivery updates.

Congratulations! Now you have officially completed the Rocketbots Academy Build a Basic Chatbot course.

There’s much more to building chatbots, so continue on to more advanced lessons, or stay tuned for more courses to come.

Your Dialogflow Tutorial is finished, happy chatbotting.

Further Reading

If your interested in using Dialogflow together with Rocketbots you'll want to check out the following:

Gerardo Salandra

Gerardo Salandra

Gerardo Salandra is the CEO of Rocketbots (www.rocketbots.io). An IBM & Google veteran, with deep expertise in growth hacking, machine learning, and chatbots. Chairman of the AI Society of Hong Kong, promoting the development and understanding of AI technologies in the Region.

Leave a Reply