Dialogflow

Dialogflow is a powerful (and free) natural language processing toolkit from Google that was designed for creating rich conversational experiences for users. Dialogflow can directly connect to various platforms, such as Facebook Messenger or Telegram, but can require custom development when you want to do more than send back simple messages to your users. By integrating Dialogflow with Flow XO, you can enjoy the full range of integrations and simple bot building tools, while adding powerful Natural Language Processing (NLP) to the Flow XO platform.

When it comes to conversational user experiences, natural language processing has three main concepts you will need to understand, all of which are fully enabled by Dialogflow:

  • Intent Detection
  • Entity Recognition
  • Slot Filling

Intent Detection

Intent Detection uses natural language processing technologies to attempt to predict what a user is trying to achieve when they type a message to your bot without having to match the users inputs exactly. For example, lets say you want your users to be able to use your bot to book a room in your hotel. One user may type: 'Please book me a room at the Ritz in New York on January 5th' while another may simply type 'I need a room'

With Intent Detection technology, these can both be detected as the intent 'book_room', along with many other variations a user may use. 

Entity Recognition

Entity Recognition is a NLP technology that uses machine learning to extract specific pieces of data out of your users input, without you having to ask for each piece of data specifically. Lets take the example above, where a user tells your bot 'Please book me a room at the Ritz in New York on January 5th'

This simple statement actually contains four valuable pieces of information:

  1. The intent - 'book a room'
  2. The venue - 'The Ritz'
  3. The location - 'New York'
  4. The date - 'January 5th'

With entity recognition, you 'train' your NLP agent with a few sample phrases and highlight the parts of the sentence that correspond to these important parameters - entities - and the NLP technology will extract these data points automatically and provide them to your bot, so that you don't need to ask the user for them explicitly.

However, in the second example of user input, 'Book me a room' - you will notice the user only provided one piece of information - the intent to book a room. But to complete a transaction, you actually need all of the parameters to be filled in. This is where Slot Filling comes into play.

Slot Filling

Slot Filling is a part of Entity Detection where the NLP agent understands what pieces of data are required to fulfill the users request, and will ask follow up questions to ensure all those data points are captured. You can do this manually using Flow XO and Ask A Question steps - but Dialogflow has this technology built in, and can continue asking follow up questions automatically until all the data you need to fulfill the users request have been completed.

Flow XO's Dialogflow integration supports connecting Dialogflow agents to accomplish each of these three important features.

Using the Integration

Flow XO exposes both a method and a trigger you can use with Dialogflow: 

  • Detect Intent (action)
  • Intent Detected (trigger)

Connecting your Account

Connecting your Dialogflow account is easy. On the 'Authorize the Service' screen (after you've selected the task you'd like to use) you'll just need to hit the 'Authorize' button, then enter your normal Dialogflow username and password in the new window that appears. You'll then be returned to Flow XO and your Dialogflow account will be connected to Flow XO.  

Detecting Users Intent and Extracting Parameters

The simplest and most effective way to use Dialogflow with Flow XO is to set up a Catch All trigger in Flow XO that immediately passes the raw message typed by the user to Dialogflow's Detect Intent method. Dialogflow will interpret the input, determine the users intent, extract any entities, decide whether or not the conversation is complete or requires follow up information, and pass all of this information back to Flow XO.

In general, the steps you will follow are these:

  • Begin your flow with a Catch All trigger, that matches user inputs not directly matched by a more specific Flow XO trigger
  • Pass that input to the Detect Input method of the Dialogflow integration
  • Inspect the response to determine if Dialogflow has indicated the interaction is complete
  • If the conversation is NOT complete, Dialgflow will provide the text of a follow up question
    • Ask the user the follow up question
    • Pass the answer back to Dialgflow via another call to Detect Intent
    • Again, inspect the response for whether or not the interaction is over. If so, continue the flow. If not, repeat the Question -> Detect Intent cycle.
  • If you are using Entity Detection, inspect the parameters which contain the detected entity values, such as the name of a hotel or a users e-mail address
  • Fulfill the users request, or continue the conversation within Flow XO

Inputs

Agent (required): The agent parameter will determine which Dialogflow agent you want to use for intent detection. An agent is really just a Dialogflow project, and can include any number of intents and entities, allowing you to specify a very rich bot that can handle a wide variety of user inputs. Flow XO will extract a list of all the agents you have built under the account you connect for you to choose from.

Session ID (required): Dialogflow uses 'sessions' to have a contextual conversation - meaning that how Dialogflow interprets input will change based on the state of the conversation. This is particularly important for Slot Filling - for example if your users types 'Book a room', Dialogflow may respond with 'What hotel?' and will be expecting a hotel name next. The easiest field to use for Session ID is the identifier of your end user.

User Input (required): This is the text that will get sent to Dialogflow to perform intent detection on. It will usually just be the 'message' of a Catch All trigger, but it can be any text you choose.

Expected Parameters (optional): This field is advanced and should be used when you have Dialogflow set up to perform Entity Detection. You will put the name of each entity your Dialogflow agent is configured to detect, separated with a comma, and these will be fields available in the Output of the Dialogflow integration. For example, if you define the entities (parameters) of hotel_room and city in your Dialogflow agent, you will put "hotel_room, city" and those two fields will be added to the output properties you can use in your flows.

Language Code (optional): If your bot is in a language other than US English, you can put the language code here. Here is a list of languages that Dialogflow supports and their corresponding codes.

Outputs

When you call Detect Intent, the Dialogflow integration will respond with some standard fields that you can use in the rest of your flow:

Response ID: This is a unique identifier Dialogflow associates with each call to its API

Action: If you defined an 'action' for your intents, this will be populated in the Action property.

Fulfillment Text: When you define an intent in Dialogflow, you can optionally specify the way you want the bot to respond to each intent. This is most important when using the Slot Filling or more advanced 'Contexts' inside of Dialogflow agents. If you want to use this feature, you will usually pass this property to a Send Message or Ask a Question task inside of Flow XO to send the message to the user.

Intent: This is the name of the intent that Dialogflow detected from your users input. 

Intent ID: This is simply a unique ID associated with each intent - you will generally not need to use this.

Is Conversation Complete: If you are using Slot Filling or Contexts with your Dialogflow agent, this property will determine if Dialogflow believes the interaction is complete and ready for fulfillment, or if there are more questions/answers necessary to complete the interaction. If you use this property, it will generally be to control a loop inside of Flow XO where you will continue to send the Fulfillment Text to your users as an Ask A Question step and send the response to Dialogflow until this property becomes True, in which case you can then fulfill the request using another integration or continue with your flow.

Parameters: Each of the parameters you specified in the 'Expected Parameters' input will be included as a separate property. If Dialogflow was able to detect a value for the parameter, that value will be in these properties.

FAQ

Any question on using this service we haven't answered?  Contact us!

Known Issues

We don't have any known issues at the moment - everything should work just fine :)

Let us know how we can improve Flow XO on our feedback site.

Still need help? Contact Us Contact Us