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 in to your bot. Or, now you can integrate Dialogflow directly to your bot to create 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 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 better understanding about Dialogflow? Please visit Dialogflow official website

Why using Dialogflow for chatbot and how does it work?

Chatbot is redefining customer experience and the way they 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 certain text that are predefined in a predicted orders. 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 users’ input. It can pick out any important words and phrases from user's input and proceed at once.

With Dialogflow integration

Without Dialogflow integration

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

How to build a BotStar chatbot using Dialogflow?

We’re excited to release feature direct integration with Dialogflow in February, 2020. Since our core value is building a platform that is friendly to use with both tech and non – tech people, you can now add this advanced conversational tool in your bot just by drag and drop block Dialogflow in the flow.

What you need to do:

  • Create an agent in Dialogflow
  • Connect BotStar to Dialogflow
  • Drag and drop Dialogflow into bot flow and complete some basic settings

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 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, responses 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 BotStar bot to Dialogflow

After the above steps are done, you now have an 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. Default agent is the agent that will be selected as default whenever you create a new Dialogflow block.

3. Set up Dialogflow block and learn about some basic elements

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 Dialogflow block into the flow editor. Dialogflow block in BotStar receives user's response, sends it to Dialogflow engine to get the data analyzed and sends back the proper response to user.

For Dialogflow block to work, 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 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 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 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.

In our following example of Coffee Order chatbot, at block Confirm Order, when we set coffee.order-yes in Intent Validation, we also fill Conversation context with input context orderdrink-followup. In this case, It’s no longer optional to fill in this context field. For Dialogflow to handle an end-user expression like that, it needs to be provided with context in order to correctly match an intent.

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 user until fulfilling each parameter required by the expected intent. Once the retry count is used up for a parameter, block will trigger "Incompleted" outlet.

Dialogflow Data Mapping: Once dialogflow block is able to match 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 bot for later usage by mapping BotStar’s Flow variables with intent parameters.

Expect User Response: When this option is enabled, you set a condition that 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 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

Dialogflow block analyze user’s input and process into 3 outlet states:

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

Incompleted: Dialogflow cannot finish the process. This action is triggered when 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:

  • User’s response doesn’t match with any available intents in your agent

  • User’s response matches with an intent in 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 disable inside the Integrate setting field.

Use Keyword and Dialogflow block in one bot flow

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

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

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

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

Learn step-by-step how to build a BotStar chatbot using Dialogflow

At this stage, you may have a certain understanding about 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 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.

Before you follow this instruction, make sure you already finish these two steps:

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

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

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

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

  • If Dialogflow block returns Failed result (did not match order.drink intent), user will be led to block 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. Set up Ask for ordering block

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

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

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

2. 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 Ask User with block Order Drink. In the setting field, you will define how you want 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 ours – Coffee shop agent.

  • Input: Set as default as latest user response

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

  • Turn on Expect User Response because we expect user to reply the text response from this intent once 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.

3. Create a confirm order block

When user’s input contains all intents we need for Order Drink block, a predefined response will be sent back to user.

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?

The setting will somehow follow our above instruction. However, you have to fill in Conversation context section since it's no longer optional. This intent requires a context for Dialogflow to match with the right intents.

Enter exactly the name of the input contexts – order.drink-yes for this setting.

At this stage, we design the chat flow with 2 outputs.

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

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

4. Create Variables and save data collected by Dialoflow to bot for future usage

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

Head to Data Panel, click on button +, create variables that correspond to user’ intent you want to save. It is not only for saving purposes, 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

We need 3 types of information in order to finish a coffee order.

  • {drink}
  • {quantity}
  • {type of delivery}

Mapping the 3 above variables you created with intents in Dialogflow in Dialogflow Data Mapping section as shown in below image.

Whenever a new customer opens our bot and place an order, these information will be automatically saved in bot

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

5. 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!