Wit.ai is a free natural language processing toolkit from Facebook that was designed for creating rich conversational experiences. Wit.ai is a simple NLP tool that can be used to extract useful information from a users input that can allow you to make your Flow XO flows more robust in the face of free-text chat inputs from your users.
When it comes to conversational user experiences, natural language processing has two main concepts you will need to understand, both of which are fully enabled by Wit.ai:
- Intent Detection
- Entity Recognition
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.
It is important to note that Wit.ai implements Intent Detection as just another case of Entity Detection (see below). This makes it somewhat less powerful than, say, Google's Dialogflow, but if you just need some quick and dirty NLP, Wit.ai can be a good choice.
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:
- The intent - 'book a room'
- The venue - 'The Ritz'
- The location - 'New York'
- 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.
Using the Integration
Flow XO exposes a single method you can use with Wit.ai:
- Detect Intent
The Wit.ai integration also provides the following trigger:
- Intent Detected
Connecting your Account
You will authorize your Wit.ai projects using an Authentication Token that is provided by Wit.ai.
Detecting Users Intent and Extracting Parameters
The simplest and most effective way to use Wit.ai 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 Wit.ai's Detect Intent method. Wit.ai will interpret the input, determine the users intent, extract any entities and return that data is parameters 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 Intent method of the Wit.ai integration
- Inspect the Intent and Parameter properties of the response and fulfill the users request using a different integration, ask follow up questions using Ask Question actions, or continue your flow in any other way you choose.
User Input (required): This is the text that will get sent to Wit.ai 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 Wit.ai project is configured to detect, separated with a comma, and these will be fields available in the Output of the Wit.ai integration. For example, if you define the entities (parameters) of hotel_room and city in your Wit.ai project, you will put "hotel_room, city" and those two fields will be added to the output properties you can use in your flows.
Minimum Confidence (optional): This is an advanced field that controls how confident you require Wit.ai to be in its prediction before the result can be used. The confidence score is a number between 0 and 1, where 0 means no confidence, and 1 means 100% certainty. This field can usually be ignored, but if you find that the integration is falsely detecting a lot of inputs or not detecting perfectly valid inputs it can be tweaked up or down.
Version (optional): This it the version of your Wit.ai model to use. See the Wit.ai documentation for how it can be used.
Intent Entity Name (advanced): Wit.ai's version of Intent Detection is really juts a special case of Entity Recognition - Wit.ai projects start with a default entity with the name 'intent' - you will usually not need to change this
When you call Detect Intent, the Wit.ai integration will respond with some standard fields that you can use in the rest of your flow:
Response ID: This is a unique identifier Wit.ai associates with each call to its API
Intent: This is the name of the intent that Wit.ai detected from your users input.
Parameters: Each of the parameters you specified in the 'Expected Parameters' input will be included as a separate property. If Wit.ai was able to detect a value for the parameter, that value will be in these properties.
Any question on using this service we haven't answered? Contact us!
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.