The Mobi Developer Hub

Welcome to the Mobi developer hub. You'll find comprehensive guides and documentation to help you start working with Mobi as quickly as possible, as well as support if you get stuck. Let's jump right in!

Get Started    

Dialogflow

Don't have an Instabot account yet?

Dialogflow node requires Standard tier and up

Using advanced functionality in Instabot such as the Dialogflow node requires your Instabot account to be on the Standard tier or higher.

To upgrade to the Standard tier, click here, or emails help@instabot.io!

1. Overview

The Dialogflow node incorporates Google's Natural Language Processing (NLP) and machine learning expertise directly into your bot to provide your users rich, natural language comprehension in free-text nodes.

Dialogflow can be useful for responding intelligently to a user's free-text, natural-language requests such as "how much does your product cost?"

Below is our own bot that uses Dialogflow to handle free-text questions - we use this bot on our main marketing site instabot.io! Test it out yourself!

In this tutorial, we will build a very simple bot that will:

  • ask the visitor a question
  • send that question to Dialogflow and display Dialogflow's response directly back to the user!

Let's get started!


2. Connect your Dialogflow account to Instabot

To connect your Dialogflow NLP agent to Instabot, retrieve and upload your Dialogflow service account key.

  1. Log into the Dialogflow console

  2. In the top-left, find the agent you want to connect to Instabot, click the gear icon to open the agent's settings page, then under "Google Project", click your service account.

Open your Dialogflow service account

Open your Dialogflow service account

  1. Find the row for "Dialogflow Integrations", click the 3-dot menu on the right, then create a key of type "JSON"
Generate a JSON key

Generate a JSON key

  1. Upload the key into your Dialogflow integrations page
Upload your JSON key

Upload your JSON key

  1. Lastly, make sure you click "Save" in the top-right corner.

Now you're ready to add a Dialogflow node into your bot!

Ensure that you are using V1 of Dialogflow. We are aware that they are deprecating this version of the API, we will provide tools to migrate the API well before the deprecation date.


3. Add a Dialogflow node into your bot

Once you've uploaded your service account key and connected Dialogflow Instabot, we're ready to add Dialogflow into your bot! Our bot will need a minimum of two nodes:

  1. a free-text node that asks the visitor for their question
  2. a Dialogflow node to send the visitor's question to Dialogflow, and display Dialogflow's response back to the visitor

--

  1. Add a free-text node to ask the visitor for their question, and click "Add Node"

Name this node

For this integration to work properly, it's critically important to name this free-text node in a very specific way. We strongly suggest naming this node "user-question".
If you want to use your own name, do not use spaces or dots in your node name, use dashes to separate words in your node-name instead (eg: "ask-visitor-something")

Free-text node to ask for the visitor's question

Free-text node to ask for the visitor's question

  1. After the user-question node, add a Dialogflow node - in the first field, type the name of the user-question exactly as it appears in step #1, then click "Add Node"
Add a Dialogflow node

Add a Dialogflow node

  1. Optionally, you can add a multiple-choice node that gives the user an option to ask another question to Dialogflow. Otherwise, you can keep the conversation going by adding other nodes as you see fit.
Give the visitor an option to add another question

Give the visitor an option to add another question

That's it! This bot is now set up to get the user's question in the first node (user-question) and then display Dialogflow's NLP-analysis response in the next node!


4. Advanced

4a. Do not display the text responses from Dialogflow itself

The most common way of implementing Dialogflow is to configure and manage text responses for each intent directly inside the Dialogflow console, and the bot will automatically display the text response for each intent. However, some customers find it easier to manage text responses for each intent from within Instabot instead of within the Dialogflow console.

To use Dialogflow in this way, you will do two things:

    1. Disable the setting for "Display text response from Dialogflow?"
    1. Add a conditional logic node for each intent you wish to display your own text response for
  1. Disable the setting for "Display text response from Dialogflow?"
**Disable** this setting if you do **not** wish to automatically display text responses from Dialogflow

Disable this setting if you do not wish to automatically display text responses from Dialogflow

  1. Add a conditional logic node for each intent you want to display your own text response for - the example below shows me adding a conditional logic node that checks if the detected intent is "Pricing", and displays another node about pricing if so.

Also, if you have multiple intents that you want to check for, simply repeat this step by adding another conditional logic node to the first "False" path that checks for the second intent, and the third intent, and so on.


4b. Route the user to different paths in the bot if Dialogflow returns the Default Fallback Intent

Sometimes all you care about is detecting if Dialogflow couldn't understand the user's question (Default Fallback Intent), and then sending that user down a specific path to escalate their query to a human or get more information from them.

To use Dialogflow in this way, you will do two things:

    1. Enable the setting for "Display text response from Dialogflow?"
    1. Add a conditional logic node to check specifically for the Default Fallback Intent
  1. Enable the setting for "Display text response from Dialogflow?"
**Enable** this setting to automatically display text responses from Dialogflow

Enable this setting to automatically display text responses from Dialogflow

  1. Add a conditional logic node that checks for the Default Fallback Intent from Dialogflow, and sends the user down different paths depending on if yes or not.
Add a conditional logic node

Add a conditional logic node

  1. Finally, add a node to each conditional node path that will send a user to when:
  2. Dialogflow detects Default Fallback Intent
  3. Dialogflow detects an intent that is not the Default Fallback Intent

4c. Access the full JSON payload returned by the DF node

Now you know how to do dynamic routing based on the detected intent returned in the JSON payload of the DF node, but what if you need to access more stuff in the JSON payload.

Using the script node, you can access any field that's returned in the JSON payload of the detectIntent#QueryResult call.

// make sure the case of dfnodename matches EXACTLY your Dialogflow's node name
var dfnodename = "dialogflow";
var dfjsonpayload = context.getResponses()[dfnodename].objValue;

// insert logic to parse out whatever you're looking for in the JSON response payload
// eg: get queryResult.intent.displayName
console.log("intent displayName = " + dfjsonpayload.queryResult.intent.displayName);

next();

For more information on what else you can do after you've parsed the JSON response payload, see our script node documentation

If you need help with anything here, please email us at help@instabot.io!

Dialogflow


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.