Creating a simple conversational speech bot using Dialogflow

C

Hello There,

In this post we are going to learn how we can create a simple conversational speech/chat bot that uses artificial intelligence to aid the IT Support Services. This post just serves as a proof of concept but not a complete solution.

Knowledge Requirements

Developing this bot requires you to have knowledge on Node and AI platforms.

Approach / Design

We are going to use DialogFlow AI (Formerly API.AI) to develop an intelligent Bot that can convert user concerns into an incident in Service Now, a major ticketing tool by market share (approx 52% as of today). The approach is to develop a NodeJS Server, which will act as back end and receive user inputs and queries AI. AI here acts as NLP by processing user input and gets required information from the conversation. We use the extracted information from AI in Node and consume services of ticketing tool to perform actions.

Action could be anything that you wish to perform and some of them could be

  1. Creating a new Incident
  2. Getting the current status of an existing Incident
  3. Updating ticket with current status

Chat Bot Design

 

Build / Deployment

As you can already see from Flow diagram we have to set up AI, NodeJS Application, Sandbox for Service Now and User Interface to complete the process. Let us go through each of them

AI Platform

We have to set up AI Platform first and it requires you to learn a little about how AI works. There are four key terms that you need to know and they are

  1. Intent – To understand what user is trying to say from the conversation
  2. Entity – To capture relevant parameters from the conversation
  3. Action – Perform action based on the intent
  4. Contexts – Understanding the situation of the conversation

Please go through documentation of any AI Platform to understand these terms better and for the sake of post, we are not going to go through them in detail.

Log into Dialgoflow with your email account and create an Agent.  This Agent responds to our application requests.

Dialogflow Agent

But as of now there is nothing to respond to our application. So, Google provided a simple plugin called Small Talk. By enabling this plugin, we can right away start a basic conversation and Agent can respond to that conversation. Enable this from your side navigation bar and save the Agent.

Enable Small Talk plugin

For now, we are done with basic conversation set up and I will share complete design of AI Project in download section.

NodeJS Application

We are going to use NodeJS as a hop between user and AI to have better control over the flow and bring in any programmatic changes during the process.

We have choice to use different packages in our Node application based on our requirement and design approach that we want to follow.

      1. Express / Microsoft Bot Framework

      We need a UI Interface and we have multiple choices for this interface. We could have an experimental WebSpeech Interface to convert Speech to text and sent it to AI (or) We could use Skype chat interface. This leaves us to decide between Express and Microsoft Bot Framework and for the example, I am going to use Express.

      2. Socket.IO

      Socket.io enables real time bi-directional communication between user and NodeJS server through events and other option would be is to use asynchronous Ajax calls from the web application and provide the response in real-time back to the web application which in my opinion is not so effective.

      3. NLP/AI

      Not but not the least, we would need an NLP package to process the information that we have received from the user. Since we are talking about Google’s DialogFlow, the package required is apiai (Dialogflow is formerly api.ai). This package would need developer key and random access token for an instance and all it would take is a textRequest call to access our DialogFlow platform which we created above.

      Note: Please ensure that your design is compatible for future enhancements such as Google Actions. In case if you are writing application logic, please do it so as a programmable functions so that it can integrate well with google actions in future.

Now that application is ready, all it takes is to write application logic to read the response from AI or alternatively configure webhooks in AI and call the desired functions. For example, if the intent of the user was to create a ticket, call the function that provides the details to create ticket api of incident management tool.

In case if you are still wondering, I have github project for your reference to get you started or please feel free to leave comments below for any queries that you may have.

About the author

pavankumar.p1990

Add comment