One of the critical aspects of developing chatbot applications is to ensure that user inputs are correctly recognized and handled by the bot. While this reasoning part can be pretty simple for command-like bots (e.g. IRC or Twitch bots) that typically define a fixed and strict list of commands, it becomes quickly complicated when the bot needs to deal with natural language understanding (NLU).
There are several solutions designed to address this issue, most of them based on input examples used to train a machine learning component (e.g. Google DialogFlow, IBM Watson Assistant, Microsoft Luis) that takes care of the input understanding. Xatkit provides a generic way to transparently integrate these solutions to empower your bot with advanced natural language understanding. In the following we briefly review Xatkit’s architecture and how these recognition techniques fit in our framework, then we detail how to setup and configure DialogFlow to improve the quality of your bots (and sorry about that, but we won’t have to write any code today 🙂 ).
Intent Recognition in Xatkit
The figure below provides an overview of Xatkit architecture. Bot designers use the Xatkit modeling language to define the core features of the bot: user intents to match, actions to compute, and weave them in complex conversation flows thanks to our rule-based execution language. Then, the Xatkit runtime component manages the deployment of the designed bot (with the help of a deployment configuration file), and its execution. During this last step, Xatkit relies on an Intent Recognition Provider to understand the user intention from a given input and trigger the corresponding execution rules.
If you want more information on Xatkit platforms you can take a look at our list of supported platforms that can be plugged in Xatkit to trigger complex actions as part of the bot execution, including our brand new example to help Github users report new issues from Slack.
The Intent Recognition Provider is an abstraction layer that aims to represent any NLP/NLU library that can be used with Xatkit. Right know we provide two implementations of this component:
- A default provider based on regular expressions that is typically used for fast deployment and testing of a bot under development, at the cost of not being very powerful and flexible
- A complete implementation of DialogFlow, Google’s NLP engine, that relies on advanced machine learning techniques to give a more accurate and flexible intent recognition (as an example, our default provider only performs exact matches, while DialogFlow is able to understand variations of the same sentence).
In the following we detail how to setup Xatkit to use DialogFlow as its intent recognition provider. Note that a complete tutorial is also available on Xatkit wiki.
Create a DialogFlow Agent for Xatkit
The first step to integrate Xatkit and DialogFlow is to create a new DialogFlow agent. An agent is basically an application that will be in charge of recognizing user intentions and send them back to Xatkit (note that DialogFlow agents can do other things such as performing REST requests but we won’t focus on them in this article).
Open the DialogFlow console and select create a new agent. You are then asked to give some general information on your agent such as its name and its language(s). Once you have filled the form click on create, and after a few seconds your agent will be ready. Once this initial step is done you can open the configuration page of your agent, and note the value of the
Project ID field, we will use this identifier later to tell Xatkit which DialogFlow agent it should use.
We are almost good to go! The last step we need to perform is to configure a service account with administrative rights on the DialogFlow API. This is required by Xatkit to automatically deploy the user intents. Click on the
Service Account field, this will open the Google Cloud Platform administration page related to your agent. Navigate on
Service Accounts in the menu, and click on
Create a Service Account on top of the page. Fill the service account details form with the name of your application (e.g. Xatkit Admin) and a short description. In the next step select the
Dialogflow API Admin role from the dropdown menu and press
OK. Finally, press the
Create a key button at the bottom of the page, select the
JSON key type from the right panel, and press
Create. Save the generated key, we will use it to authenticate Xatkit.
Additional details on the service account configuration are available in the Xatkit wiki
We know have created a DialogFlow agent for our Xatkit application! The final step to perform is to update the deployment configuration file to tell the Xatkit Runtime component where to deploy the bot and give it the required credentials. You can do it by opening your bot’s
.properties file and add the following lines to it:
xatkit.dialogflow.projectId = <Your agent Project ID> xatkit.dialogflow.credentials.path = <Path to the downloaded JSON credential file> xatkit.dialogflow.language = en-US
These properties tell Xatkit to use your DialogFlow agent, and provides the path to the JSON credential file downloaded from your service account. Note that this example contains the minimal properties required to use DialogFlow from Xatkit, but intent processing can be finely configured using additional options available here.
That’s it! Your Xatkit bot is now ready to be deployed on DialogFlow and benefit from advanced intent recognition capabilities. Here are the three main takeaways of this article:
- To use DialogFlow with Xatkit you need to create a DialogFlow agent for you bot, and update Xatkit configuration file to tell the runtime component to use your agent to deploy intents.
- You don’t have to update your bot definition: in this article we didn’t change the
.executionfiles, the same definition is used to deploy the bot on DialogFlow instead of the default intent recognition provider. This means that you can easily switch from one provider to another, or benchmark which provider better fits your application!
- You don’t have to specify any intent manually in DialogFlow: the only things you need to do on the DialogFlow side are some simple configuration and credential generation. No need to learn another way to specify intents, this is handled by Xatkit for you!
This article summarizes the Integrating DialogFlow article on the Xatkit wiki. You can check it out to get more details on DialogFlow setup and Xatkit configuration, and use our example GreetingsBot to test DialogFlow capabilities.