How to make your BotStar bot smarter with Dialogflow

BotStar provides different tools to manage your bot’s responses to free-form messages from users. One option is to automate these responses using Keyword rules built right into your bot. Or, now you can integrate Dialogflow directly to your bot to create a better conversational experience with your users in a personalized manner.

What is Dialogflow?

Dialogflow is a natural language understanding platform that helps translate human language into computer language and vice versa. It also goes a step further to understand the conversation that it hasn’t been trained to understand, which makes it a great fit for chatbots. Using Dialogflow, you can provide new and engaging ways for users to interact with your business.

Need more information for a better understanding of Dialogflow? Please visit Dialogflow official website.

How Dialogflow works?

A chatbot is redefining the customer experience and the way customers interact with your businesses. Let’s assume you’ve finished creating a perfect bot for lead generating and customer support. You give users the choices and hope users click the bot’s buttons, answer all bot’s questions and type in the certain text that is predefined in a predicted order.

However, your users act differently. They input a message instead of using the quick reply or click button to begin the automated conversation and just type in what they’re having in mind.

No worries, BotStar now allows you to combine elements of Dialogflow to your bot flow without any technical knowledge required. Let's take a look at the below example at a chatbot for taking coffee orders to see how it works in BotStar.

Dialogflow can act on specific pieces of information contained within the users’ input. It can pick out any important words and phrases from the user's input and proceed at once.

Without Dialogflow integration

Without Dialogflow, your users need to go through several steps in order to complete the order.

With Dialogflow integration

With Dialogflow, customers can directly message their orders without following the designed steps.

Requirements before using Dialogflow

Before using Dialogflow in BotStar, there is some basic knowledge and steps you need to do in the Dialogflow system and the BotStar system. Here is what you need to have:

1. Create your first Agent

It all starts with getting a free Dialogflow conversational agent.

Step 1: Go to Dialogflow then login with your Google account when prompted.

Step 2: Create an agent.

Here you have two available options: create an agent from scratch or use a prebuilt agent.

  • To create your first agent, simply click on the Create Agent and start building your own agent from scratch. You may learn with detailed instruction on Dialogflow official website 😉.

  • To import a Prebuilt Agent, let's scroll down the left sidebar menu and click the Prebuilt agent, pick one and click Import. You may take a look at Dialogflow instruction for further details.

Once it's done, Dialogflow will redirect you to the main page. You will then customize or make any adjustments here to perfect your agent. There are three main sections for you to perform the work.

  • Left: The left sidebar menu.
  • Middle: Working Area where displays all of your intents, response settings, etc.
  • Right: Test Area to test how it’s going to work based on your settings.

Here is what you will see inside your agent.

2. Connect your bot to Dialogflow

After the above steps are done, you now have a Dialogflow agent ready to be used in BotStar. Next, head to Integration, click Connect to get your current Dialogflow account linked to your BotStar account.

You may consider using option Select Default Agent to cut down on the time it takes you to pick an agent for all blocks. The default agent is the agent that will be selected as default whenever you create a new Dialogflow block.

3. Elements of Dialogflow block

Before you go ahead and start using Dialogflow for your chatbot, it’s important to understand some basic elements.

Dialogflow block: You can use Dialogflow in BotStar just by dragging and dropping the Dialogflow block into the flow editor. Dialogflow block in BotStar receives the user's response, sends it to the Dialogflow engine to get the data analyzed, and sends back the proper response to the user.

To make the Dialogflow work in the flow, you need to complete the settings for the below elements.

Dialogflow agent: Agents in BotStar are all listed from your Dialogflow account. An agent here contains all the data you’ve created on the Dialogflow side.

Input: Latest user response is the user response right on the previous block. This value will be sent to Dialogflow for information analyzing.

Intent validation: The intent that you expect will match with the User’s input. It helps determine where a conversation will go. Defining a specific intent for one Dialogflow block will help it narrow down the list of intents it will search to match with the user's input.

If the input doesn’t match with your selected intent, this block will immediately trigger the "Failed" outlet.

Note: You can also select option Any Intent, which means User’s input can be mapped with any intents that are available in your agents. This option is helpful for building FAQ chatbots, where you can support customers without collecting data from User.

Conversation contexts: Conversation contexts is the method for you to control the flow of a Dialogflow conversation. Once you set the conversation context for a Dialogflow block, it is more likely to match intents configured with input contexts that correspond to these conversation contexts. Thus, you should have all input contexts of the intent you want this Dialogflow block to detect filled in this field.

If you choose Any intents for Intent Validation but expect some specific intents to be matched, you may enter input contexts of these intents in this Conversation context.

Parameter Complete Retry Count: When an intent is matched at runtime, Dialogflow provides the extracted values from the end-user expression as parameters. How many times Dialogflow will ask the user until fulfilling each parameter required by the expected intent. Once the retry count is used up for a parameter, the block will trigger the "Incompleted" outlet.

Dialogflow Data Mapping: Once Dialogflow block is able to match the user’s input with any expected intents and collect some information (Dialogflow block triggers either Incompleted or Completed outlet), you can save that information in your bot for later usages by mapping BotStar’s Flow variables with intent parameters.

Expect User Response: When this option is enabled, you set a condition that the user needs to type something in order to continue the bot flow. You can also select one of the Response Validations in BotStar as a requirement for the user’s input and to make sure their answers match with the type of answer or format you expect.

Create a Dialogflow block and you can now do a custom integration in a few simple steps.

4. Outputs of Dialogflow block

The Dialogflow block analyzes the user’s input and process into 3 outlet states:

Completed: User’s input contains data that successfully matches the intents set up in Intent Validation and meets all required intent parameters.

Incompleted: Dialogflow cannot finish the process. This action is triggered when the user’s input contains information that matches some but not all required intent parameters. When Dialogflow will return this result depending on your setting for how many times your user can answer one question in Parameter Complete Retry Count.

Failed: The block generates Failed output after it fails at matching any intent when either of the below cases happens:

  • The user’s response doesn’t match with any available intents in your agent.

  • The user’s response matches with intent in the agent but doesn’t match with any intents you select in Intent Validation.

Note: Dialogflow blocks always trigger “Failed” if the connection between BotStar and Dialogflow is disabled inside the Integrate setting field.

Keyword and Dialogflow in one bot

You can now use both Keyword and Dialogflow to enrich the conversation and user experience with BotStar.

The keyword is a list of acceptable text responses. It helps trigger a certain predefined answer or any specific block if the chat user types something that matches a predefined condition. Want to get a better understanding and how to use Keyword in BotStar, click this link 😃.

Specifically, you can set up a keyword to trigger the Dialogflow block. Whenever users enter messages that match with one of the keyword settings, the Dialogflow block will prompt no matter where that user is in the conversation. In this case, the message that triggers the keyword will be the input of the Dialogflow block.

In the following, we will guide you shortly on how to build your own BotStar chatbot using Dialogflow.

How to build a chatbot using Dialogflow

At this stage, you may have a certain understanding of Dialogflow flow and how it works in BotStar. Let’s practice with a real example!

Here we’ll walk you through the process of creating a BotStar chatbot for coffee ordering with Dialogflow integration. We choose a coffee shop as a sample agent. This agent’s available and free on your Dialogflow account so you can jump on the documentation and practice hand in hand right away.

The flow covers some typical actions that happen in an ordering process.

  • Bot asks for the user’s response, Dialogflow will pick up words and phrases to match with pre-define intents.

  • The user’s response is processed and the Dialogflow block generates a Completed result (all required data is collected). You can save this information and use it to confirm the order and save these data in bot.

  • The user’s response is processed and the Dialogflow block generates an Incompleted result (only some required data is collected), the bot will trigger block Notify Admin asking for help.

  • If the Dialogflow block returns the Failed result (did not match order.drink intent), the user will be led to blocking Failed and may try to order again.

The below image will give you a bird's eye view of the entire sample coffee order bot flow.

1. Import a prebuild agent and integrate it with BotStar

Step 1: Log in to your Dialogflow account > Click Prebuilt Agents by strolling down the dashboard on your left.

Step 2: Import the Coffee Shop template.

In the Coffee Shop template, we will focus on collecting customer orders through the order.drink intent that has two follow up intents are order.drink - no and order.drink - yes.

Step 3: Integrate the Dialogflow with BotStar. Let's Take a look back at how to enable Dialogflow option in BotStar here😉.

2. Create Variables and save data collected by Dialogflow

You can create Variables to save and manage user's input collected by the Dialogflow block in BotStar.

Head to Data Panel, click on button +, create variables that correspond to the user’s intent you want to save. In this example, we need three types of information in order to finish a coffee order. So whenever a new customer opens our bot and places an order, this information will be automatically saved in the bot.

Saving data in variables is not only for storing information, you can also use this data to send your bot messages so you can keep users progressing through your flows and meet your marketing objectives. Want to learn more about Variables in BotStar? Here is the link to our documentation.

3. Set up Collect Order block

You can design a block asking for various types of user inputs with Dialogflow using text block, quick reply buttons, block asking for the user requests.

We are going to create a simple text block asking for user response Would you like to order?

Don't forget to enable Expect User Response so bot won't move on unless it already collects the user's input for the Dialogflow block.

4. Set up Order Drink block

Drag and drop Dialogflow block into flow editor. We want our bot to handle all the drink orders, thus, we name this Dialoglow block “Order Drink”.

Let’s see how it's set up to work properly in BotStar.

Connect block "Collect Order" with block "Order Drink". In the setting field, you will define how you want the Dialogflow block to work.

  • Dialogflow agent: Click on the drop-down, you can see a list of available agents that you have created in your Dialogflow account. We’ll choose our – Coffee shop agent.

  • Input: Set as default as the latest user response.

  • Intent validation: Choose the order.drink intent you previously train in Dialogflow to trigger Intent that produces the correct response for your user.

  • Turn on Expect User Response because we expect the user to reply to the text response from this intent once the Dialogflow block is Completed.

  • Conversation context: You can leave it blank because this intent doesn’t require any inputs context in order to be matched with this intent in Dialogflow.

5. Create a confirm order block

According to the template "Coffee Shop", after collecting all intents we need for the “Order Drink" block, we will have a follow-up flow to ask confirmation from the customer. For example:

Customer: Could you deliver a large cup of coffee to my office now?

Bot: You want to order one coffee, large size, delivery. Is it right?

At this point, you will need to have another Dialogflow block to continue the confirmation process, which we call the “Confirm Order" block. The chat flow will have 2 outputs:

  • If the bot receives the answer Yes (or any other words with the same meaning), it will continue the conversation flow to finish the order.

  • If the bot doesn't get the right answer from the user to proceed with the order, (user may type in No or any other words that the agent isn't capable of recognizing) block Cancelled will pop up.

The setting will somehow follow our above instructions. However, you have to change the Intent Validation to order.drink-yes and fill in the Conversation context section since it's no longer optional. For Dialogflow to handle an end-user expression like that, it needs to be provided with the context in order to correctly match an intent.

The order.drink-yes intent requires a context for Dialogflow to match with the right intents. Enter exactly the input contexts - orderdrink-followup for this setting.

All is set! Test to see the result and how it works in the short video below 🥳

6. Manage Keyword together with Dialogflow

You may choose to trigger keywords with different conditions. I present here just a simple use case, I set up keywords that contain Latte or Coffee, so whenever a user enters a message that contains these words, block Dialogflow Order Drink will be triggered and they can order right away without having to strictly follow the entire bot flow.

See? you can now create a very smart chatbot with only a few simple steps. Let’s build yours and enjoy the result!


Did you find it helpful?   Yes   No