Dialogflow based Chatbot to resolve Admission Queries of the Users
Tags: Dialogflow, Flutter, devgrad2020, octograd2020
Published: 2020-05-22 15:07:23

**INTRODUCTION**

Chatbot is widely popular now-a-days and catching speed as an application of computer communication. Some programs respond intelligently like humans. This type of program is called a Chatbot. Traditionally, to get a question answered by a software program involved using a search engine, or filling out a form. A chatbot allows a user to simply ask questions in
the same manner that they would address a human. The most well known chatbots currently are voice chatbots: Alexa and Siri. However, chatbots are currently being adopted at a high rate on computer chat platforms.

I am working on developing a chatbot to answer admission related queries of students which they have while applying for admission in Engineering faculty of DEI. After closely analysing different cloud technologies which are available I decided to go ahead with the development of
chatbot with dialog flow.

**DIALOGFLOW**

DialogFlow (previously called API.AI) is a conversational agent building platform from Google. It’s a web-based platform that can be accessed from any web browser. The tool has evolved over time from what was built as an answer to Apple Siri for the Android platform. It was called SpeakToIt, an Android app that created Siri-like conversational experiences on any
Android smartphone.

**PROJECT DESCRIPTION AND SOLUTION**

Students who apply for admission in DEI have numerous queries in their mind, based on the answers of which they choose their courses for graduation or post-graduation. So, in order to reduce the amount of questions being asked at the admissions office of DEI, I am trying to replace the majority of the work by deploying a chatbot which will be able to answer the majority of the general questions of students. However, currently I am working on towards developing it focused mainly on the engineering faculty.

The students/users should be able to access the chatbot from anywhere with internet access. It is important to note that the chatbot will answer only the questions regarding the admission procedures and other general questions and not give the facility of tracking their application
status to the user.

**SOME SAMPLE QUESTIONS**

Question 1 : What are the branches in Engineering faculty of DEI?
Answer 1 : There are four branches, namely Electrical, Mechanical, Civil and Footwear
Question 2 : What are the choices available for specialization for the students of the Electrical Branch?
Answer 2 : There are three choices available: Electrical Core, Electronics and Computer Science
Question 3 : What are the courses of computer science taught in first year?
Answer 3 : Students will be taught C programming language in the first year
Question 4 : How are the placement records of students of Electrical branch in DEI?
Answer 4 : The placement records are good, almost all students get placed while some opt for higher studies

**Note:** DEI is the name of my University and it stands for Dayalbagh Educational Institute

**GATHERING INFORMATION AND CREATING THE DATA**

One of the best way to gather information and getting the relevant data from it is by using a Questionnaire and distributing online to the students of DEI. This will reach a large user group, producing a diverse and varied result set for analysis providing detailed scope on what users i.e. the students might expect from an application such as this. It will give valuable insight into the kind of questions that might be asked regarding the admission procedures, how often the users preferred using services of a chatbot. This questionnaire was developed on Google Forms which stores all the fields values in an excel sheet in Google Sheets which can be uploaded to the Dialogflow platform and questions as well
as their responses can be stored there as well.

This questionnaire will provide a great understanding on how the public would respond to using a chatbot to assist them with the doubts regarding the admission processes of DEI.

**FUNCTIONAL REQUIREMENTS**

• Users will be able to converse with the Chat bot through text commands and it will understand what the user is saying through natural language understanding processing provided by the Dialogflow.
• The chat bot should be able to maintain the conversational state when the context may be unclear through previous messages and conversations.
• Provide text and audio responses.
• Since an android app is also developed therefore the chatbot also needs to stay connected with the android application at all times.

**NON-FUNCTIONAL REQUIREMENTS**

• Chatbot’s response time should be less than 5 seconds i.e. it should be efficient with a little lag in response.
• Chatbot and the database must be secured.
• The database must be scalable to support large number of users.
• Giving the correct or appropriate response to the user when the chatbot doesn’t understands any query put forward by the user.
• Use Natural Language Understanding for better results.• Promoting the correct or appropriate response given to the user when the chatbot doesn’t understands any query put forward by the user.

**SOFTWARE REQUIREMENTS**

• Google Assistant
• Android App which is connected to the chatbot (optional)

**HARDWARE REQUIREMENTS**

• Android Phone (if using the android app otherwise web-app will work on any phone)

**RISK MANAGEMENT**

There is a need for having a version control system in place so that any work if gone wrong can be reverted to the previous working states. Therefore, through GitHub’s private repository I took the backup of the code to prevent any loss, regularly made backups of project.
Designing the Conversation Google has laid out bunch of rules and guidelines which needs to be followed to have our chatbot on Google Assistant which gives a seamless conversation experience to the user.
System and Users Persona.

Before we decide the dialogs for the conversation, we need to have a clear picture in our mind about who the characters are and personas are the tool to do just that. The system persona is the conversational partner created to which the user will interact directly. Defining a clear system persona is important to ensure a consistent user experience. Otherwise, every designer will have to follow their own personal conversational style and the overall experience will feel disjointed.
It is important to note that everywhere Google Assistant evoke a consistent persona.

**CONNECT THIS CHATBOT WITH AN ANDROID APP**

I am using **Flutter** to develop the App. In the app I have added a chat-message icon which will invoke and start the conversation with the chatbot. Clicking on this icon will open a new page, containing an input text box for the user to enter their query. For every query entered by the user, we’ll fetch a response into the app from the chatbot.

I am using page routing in the app to navigate between the pages. The page that gets launched once the user clicks on the icon atthe bottom of the page is basically a stateful widget which will have the current list of the conversation history of the user and everytime the user comes back to the first opening page of the app, the chat history will get cleared. In the list section I have followed a reverse order approach which neccessarily means that the latest chat message will get displayed first which is usually the same everywhere.

There is a widget called queryinput which have two sections, firstly the text box where the user will type their query and secondly the icon to send the message or the query. There are two types of messages:

1. Message of User
2. Message from Chatbot

When the query gets submitted, the message from the chatbot is rendered just below the message of the user and this is exactly how the query gets submitted to the Dialogflow API through the flutter’s api for dialogflow.

**Ongoing Tasks, Problems and Solution:**

• There are people who still dont have a smart phone, so for them I am integrating this whole solution with the twilio SMS Services on a free account and in future will also have it integrated with a call service.

**Demo of the Chatbot working in the App:**

I'll soon update this post with the link of the video demonstrating the working of the chatbot.

**RESULT: WHAT IS THE FINAL OUTCOME ?**

The Chatbot which is fully developed on Google Cloud Platform and is integrated with services and API’s along with provision for tonnes of future development prospects.

Following are the key features which are currently present in my project:

**• Accessibility:**

Chatbot can be accessed from anywhere in the world through 5 different platformsas of now.

o Google Assistant
o Android Mobile Application
o Web Application
o Dialogflow Messenger
o Dialogflow Phone Gateway

**Future Development and Integration Prospects:**

o Twilio Messaging
o Genesys Cloud
o SignalWire
o Avaya
o VoximPlant
o AudioCodes
o Slack
o Telegram
o Amazon Alexa

Two new additions in my project besides the previously explained and shown Android App, Google Assistant and the Web App are

**Dialogflow Phone Gateway:**

Dialogflow provides the user a single click integration facility to integrate the chatbot with a telephony service. So, when this service is switched on for use, it first asks theuser to select a country for using the phone service for that country which for now is United States only and choosing a region in US is optional.

The country available and selected is United States. Then we will be given couple of numbers which are phone numbers out of which we have to choose one. We have 3 choices to choose from. As soon as we press ‘Create’ button, we will have that chosen phone number assigned to our chatbot which we can call and then start the conversation by saying “Hi”.Dialogflow Messenger:

Dialogflow brings a rich UI for Dialogflow to enable developers to easily add conversational agents to their websites. It provides customizable chat dialog for our chatbots that can be embedded in our websites. The chat dialog is implemented as a dialog window that can be opened and closed by our end-user. When opened, the chat dialog appears above our content in the lower right side of the screen.The above figure shows how the chatbot would look like on a web page.Android App
The production version of the app hasn’t been launched yet and the following has been done:

**Registration Page**
**Login Page**
**About Us** 
**Page:** redirects to a webpage which has in-depth information about the project
**Home Screen with Chat Button to get routed to the chat box.**
**Chat Box or the page where user sends the query and receives the response.**
**List view design for scrolling of the chats to see the chat history.**
**Connectivity with the Google Cloud Platform and its APIs.**

Note: One of the major benefits of this project is that it is Highly Cost Optimized or in other words, the cost is kept as minimum as possible.
Solution to the Problems faced in the project:

While working with the development there were certain problems I faced and now I have the solution ready for that.

Problem 1: Searching the documents on the website of DEI and returning response from that.

Solution : I found 3 solutions/approaches to solve the problem.
**1. Apache Lucene based Apache Solr or Elasticsearch and Big-Query:**

The pdf file has to be indexed. This indexing would be done using either Apache Solr or Elasticsearch which are developed on Apache Lucene. The output file would be a JSON document containing the relevant information. This JSON file will be uploaded to Big-Query from where whenever the seperate intent in the Dialogflow intended for getting response from Big-Query. Whenever that particular intent will get invoked by the user,
the query would be sent over to the Big-Query and from there the response will be returned.

**2. Google Drive SDK:**
Google provides a way to search the pdf documents stored in the Google Drive using theGoogle Drive’s SDK.

**3. Knowledge Base:**
Dialogflow provides a way to upload documents on its platform and generate response from that when no other intent is able to return the response to the query of the user.
Note: I am not going forward with the 3rd solution i.e. Knowledge Base because it is currently a beta version and not a stable version. However the first and second solution are effective and I am working on them currently. The code-base for both would be on Cloud Functions and the final solution would be the one which would be most cost effective which can be tested only when both the solutions would be prepared. For the first solution I have the integration of Dialogflow with the Big-Query ready but not deployed since the other part which will be creating the index of the document is still under progress.

**Features to be added in the future :**

• Subscription to a mail list feature for the end user which will enable the admission authorities to send a notice or announcement directly into the mail box of the user (this is in the case where our user is a smart-phone user). This feature for the android app is ready but is yet to be tested.
• Regular registration and login facility is currently in the app but in future social media login facility with user’s account authentication via OTP on email or phone number system can be added.
• Facility to send an email to a professor to fix an appointment with him/her which will be raised by the user and accepted by the professor. Although I have the system ready which will book the appointment but this system won’t ask for the permission of the professor so it hasnt been integrated yet.

**PS: I will soon update this post with the link to the video demonstration of the project as well as the github url for the code.**
It is my first ever post anywhere and I am really glad that finally I made one, I request the readers to point me to the areas of improvements.