Degree Thesis
HALMSTAD
UNIVERSITY
Computer engineering, 180 credits
Chatbot
The future of customer feedback
Degree thesis, 15 credits
Kevin Hoang Dinh
Acknowledgements
I would like to express my deepest appreciation to Magnus Olander from Quicksearch and Ludvig Linse from Narratory for providing me materials and helping me with technical issues. Without their help, this study wouldn’t be possible.
I also thank my advisor, Eric Järpe, for helping me with writing my thesis and giving me lecture on hypothesis testing.
In addition, a thank to my friend Carl Thomsen for proofreading, fixing my spelling mistakes, and supporting me through this period.
Last but not least, I would like to thank my family and friends for their mental support
during this corona period. It has been a lot of stress for me in these tough times and I almost
gave up half-way through this study. Thanks for their support I’ve managed to push through
and finish it.
Abstract
This is a study about how to convert a survey to a chatbot and distribute it to various
communication channels to collect feedback to improve themselves. What would be the
most convenient way to gather feedback? Our daily lives are becoming more and more
dependent on digital devices every day. The rise in digital devices leads to a wider range
of communication channels. Is it not a good opportunity to use these channels for several
purposes. This study focuses on chatbots, survey systems, communication channels, and
their ability to gather feedback from respondents and use it to increase the quality of goods,
services, and perhaps life. By using chatbot language knowledge, people can engage with the
bot in a conversation and answer survey questions in a different way. By using Restful API,
the chatbot can extract quantitative information to be analyzed for development. Although
the chatbot is not well-made and still requires a lot of adjustments, the work has proven to
have many opportunities in surveys, gathering feedback, and analyzing it. This could be an
improvement for research regarding chatbots in the future or a new way to make surveys
better.
Sammanfattning
Detta är en studie om hur man konvertera en undersökning till en chattbot och sprida den till olika kommunikationskanaler för att samla återkoppling for att förbättra sig själv. Vad skulle vara det bekvämaste sättet att samla återkoppling? Våra dagliga liv blir mer och mer beroende av digitala enheter var dag. Ökningen av digitala enheter leder till ett större utbud av kommunikationskanaler. Är det inte då en bra möjlighet att utnyttja dessa kanaler för flera ändamål. Det här arbetet focuserar på chattbotar, undersökningssystem och deras förmåga att samla återkoppling från respondenter och använda den för att öka kvaliteten av varor, tjänster och kanske livet. Genom att använda chattbottens språkkunskap kan människor engagera sig med botten i en konversation och svara på undersökningsfrågor på ett annorlunda sätt.
Genom att använda sig av något kallat Restful API kan man ta ut kvantitativ information för
att analysera den för förbättringssyfte gällande produkter och tjänster. Trots att chattbotten
inte är välgjord och fortfarande kräver mycket justeringar så har arbetet visat sig ha många
möjligheter inom undersökningar, samla återkoppling och att analysera det. Detta kan
vara en förbättring för forskning om chattbottar i framtiden eller ett nytt sätt att förbättra
undersökningar.
Table of contents
1 Introduction 1
1.1 Objective . . . . 2
1.2 Research questions . . . . 2
1.3 Limitations . . . . 2
2 Background 3 2.1 Chatbot . . . . 3
2.2 Natural Language Processing . . . . 4
2.3 Extract, Transform and Load . . . . 4
2.4 REST API . . . . 4
2.5 Related Work . . . . 5
3 Method 7 3.1 A chatbot that can interact with the respondent . . . . 9
3.2 Survey/Answer file and Application . . . . 11
4 Result 15 4.1 A chatbot that can interact with respondents . . . . 15
4.2 An application to analyze the respondent’s answer and update the chatbot dialog . . . . 17
5 Discussion 21
6 Conclusion 25
References 27
Appendix A 29
Chapter 1 Introduction
Societies, organizations, and residents are becoming more dependent on digital devices.
People use computers and mobile phones to contact each other more frequently which leads to an increased traffic in these communication devices. As the number of chat channels continuously increases and becomes more common in our daily life and it also becomes more relevant to use them for different purposes. An interesting idea which connects with those purposes is Quality Control. The most commonly used form for Quality Control is a survey. Quality Control is a process to ensure the quality of a product or a service keep up to people demands. Would you want to use an ineffective product? Would you pay for a poor service? Or a medicine that barely cure your sickness? This is why Quality control is very important. Without it, the outputs’ quality will be put at risk.
The survey gives us the possibility to gather quantifiable answers from structured ques- tions which makes Quality Control easier to handle for different costumers and collaborators.
A lot of application areas are possible to investigate by means of surveys using Quality Control: errors inspection [1], crowdsourcing [2], neurochemical dementia diagnostics [3].
However, the problem with traditional polls is survey fatigue. Survey fatigue is also known as the Respondent Burden [4]. It means the polls can put a burden on the respondent. How?
Because participation in a survey can be time-consuming and require effort which makes the
respondent less likely to answer the survey. This leads to a lower response rate making the
poll’s data unreliable. Improving survey quality is more important than people think. How
will a product improve without consumers’ opinions? How can a business grow without
listening to its costumers? Things people use every day have been utmost perfect to their
needs all thanks to the survey system. Without it, our society can hardly progress onward
and stagnate. But how can we improve it furthermore? According to Angela Sinickas, the
key to improving survey fatigue is making sure that people feel their opinions are being
listened to [5]. For example, by shortening the survey the response rate can be increased
2 Introduction
significantly but the quality is greatly decreased. There is also a study about using incentive effect increases both response rate and quality but with the cost of money [6]. Online survey is less time-consuming and better cost-effective yet their sampling has issues and concerns [7].
1.1 Objective
There are many ways to improve the survey but most come with a cost. The primary purpose of this project is to create a unique way with the help of bot and chat channels to improve the response rate, quality and cost-effectiveness of surveys. After that, people can deploy the chatbot to their application, service and research to use for their own purpose.
1.2 Research questions
In order to reach the objective the project requires:
- A chatbot that can interact with the respondent. Can the chatbot understand the respondent’s answer? What will the bot do if it does not understand?
- An application which is able to generate analyzable information from the interactions with the chatbot, surveys and the respondent’s answers. How does the application send out the survey to the bot and gather answers from the conversations? Can the application also update the chatbot dialog (Answer and Question) if there is a new polls or a change?
1.3 Limitations
There are many types of surveys such as market research, employee satisfacion, training
evaluation... But the project focuses most on the use of chatbot in a survey system and how
the respondent feel about using the chatbot compared to a poll/survey. It would require a
lot of time, research and resources to go through all surveys. Additionally, the project will
focus on messenger due to limited workforce. The project also exclude the chatbot’s speech
interface due to similar reasons.
Chapter 2 Background
To answer the research questions, it requires certain knowledge and method. In this chapter, the project will go more into the theories and the materials which are used to achieve the objective.
2.1 Chatbot
Chatbots, also known as conversational agents, exploits the Natural Languages Processing (NLP) to interact with users through an interactive text- and speech-based dialog [8]. Im- plemented on many different platforms(e.g., applications, web services, chat channels), it responds to customers’ inquiries and questions. The uses of chatbots are endless as it is becoming a part of people’s daily lives. Apple’s Siri, Amazon’s Alexa and Google Assistant are well-known agents for their multi-use,e.g. training, education, booking trips, transactions, customer service or route planning [9]. Developers evolve complex agents non-stop, adding more abilities and functions. Beside these complex multi-use agents, there are agents com- mitted to a single task that can be composed through a cloud communications platform as a service (PaaS). Popular platforms that specialize in conversational chatbots are Dialogflow, Twilio and Azure Bot Service.
The development of chatbots are on the rise. From simple code patterns to a hardware
product and embedded deep-learning system, chatbots created for multiple purposes and
have proven its usefulness to many different cases [10]. Even though every chatbot has
different objectives, they are all focusing on the same field, conversational knowledge. The
oldest chatbot, ELIZA, generates its answers by matching keyword from the user’s statement
[11]. This simple implementation became the most referenced in today’s conversational
techniques [12]. By exploiting these techniques(e.g., NPL, keyword extraction, deep-learning
or machine learning), chatbots can understand the user’s input and reply with an appropriate
4 Background
answer making the conversation more human-like which encourages participants to continue using the service [13].
2.2 Natural Language Processing
Natural Language Processing (NLP) is field research about computers’ understanding of human language, including both text and speech. The essential part of all chatbots are to interpret the user’s input and give back the desired output. NLP is an accumulation of many application areas such as machine translation, natural language text processing and summarization, user interfaces, multilingual and cross-language information retrieval (CLIR), speech recognition, artificial intelligence, and expert systems [14]. NLP involves three major issues of Natural Language Understanding (NLU) that need to be solved for computers to accomplish human-like language processing. The first issue is the human thought process, the second is the comprehension of the semantic input, and the last is world knowledge, the knowledge outside the default program. In order not to confuse "processesing" with
"understanding", NLP focuses on the process of natural language interpretation while NLU focuses on the interpretation.
2.3 Extract, Transform and Load
The project’s point is to compare the normal survey to the chatbot regarding the quality, effectiveness, and response rate. In order to compare data from different sources using different formats, it needs to be extracted and transformed into the correct one. Extract, Transform and Load (ETL) is the name of the process when integrating data from multiple sources and put them together into one system. The process is as follows:
• Extract data from different channels, platforms or applications.
• Transform the data into the correct format for the targeted system.
• Load the transformed data into the system.
2.4 REST API
Representational State Transfer (REST) is a style to build distributed hypermedia systems.
HTTP (HyperText Transfer Protocol) is the main protocol for most common REST imple-
mentations. A RESTful API works around resources, which can be any kind of data, object,
2.5 Related Work 5
or a service that can be accessed through an identifier, which is an URL (a website address).
REST APIs use HTTP as a protocol so it can perform common HTTP methods. Using a resource identifier together with HTTP methods allows the client to performs common operations on resources:
• GET: retrieves a representation of the resources.
• POST: create a new resource. The client must provide the data to the new resource for creation.
• DELETE: remove a resource. The client must have identification to remove a specific resource.
This project will use REST API to build a web service to receive a POST request through a webhook.
2.5 Related Work
The project’s objective is to engage consumers in a poll through a conversational chatbot.
Similar work categorizes into two areas as detailed below.
Agents for information
Many developers have built agents to interact with their customers to retrieve information.
Knowing the information, agents can find relevant data and perform the correct task, such as education support [15], booking travel, customer service [16] or recommendations [17]. The agents will not be able to give you education support if it does not know about which education a student has. Booking travel requires a traveler’s name, credit card, and private information.
Recommendations without knowing the costumer’s references would be irrelevant and time- wasting.
There are studies about agents for gathering information but not many of them situated in a survey form. There is no consideration of the quality of information, unlike a survey. The objective of this project might be similar to other research above. But it goes further to the next step and discovers more findings to improve the survey quality.
Improving survey quality
As stated above, the main purpose of this project is to find a method to improve survey quality.
Not just this project, many other studies have put a lot of effort into improving the response
6 Background
rate. In 2006, a research has shown that personalization can increase the response rate by
4.4 percentage, from 50.3 to 54.7 [18]. Other research about interactive feedback has also
shown the improvement of web surveys [19]. Another research uses probings to produce
better quality answers from the respondent [20]. Learning from previous studies, the project
can apply these techniques on conversational agents to improve survey quality furthermore.
Chapter 3 Method
Fig. 3.1 Project Plan
When the chatbot communicates with the respondents, the chatbot will let the server
know what the respondent has answered with each interaction. The project wants to collect as
many answers as possible even if the respondent has not finished the whole conversation. The
chatbot will send the data to an application that is suitable for handling it. The application
will then convert the data to an appropriate format for a system to process. Additionally, it
requires a second application to take a survey and convert it into an appropriate script to
update the chatbot’s dialog. As shown in Fig.3.1, the project will require a chosen platform
to create an appropriate chatbot. The platform should be able to connect with different
communcation channels e.g Facebook Messenger, Slack, Microsoft Teams. Additionally,
the chatbot should be programmable since it requires to update the dialog should there be
a change in the survey. To pass the platform, the project will set up an easy survey with
branches and different kinds of answers from the bot.
8 Method
Fig. 3.2 A simple survey’s flow
There are many suitable platforms for the chatbot e.g Twilio, Azure Bot Service, Di- alogflow, and Manychat. Twilio’s autopilot is a conversational Artificial Intelligent (AI) to create agents and train them with NLU and machine learning
1. Same with Azure Bot Service, their Virtual Assistant uses a machine learning-based service to increase their language experiences, Language Understanding Service(LUIS)
2. Azure, Dialogflow, and Twilio can integrate with many different platforms and even have a speech pattern. Manychat’s flowchart allow users to create more flexible chatbots. These platforms have been used in various research before: using Azure to create a chatbot application for Slack [21], using Twilio to create a chatbot for healthcare [22], and Dialogflow for Placement Activity at College [23].
However, this project will use Narratory. Narratory is a platform that uses Dialogflow as its core and codes the agent through Typescript programming languages. Twilio can not create the chat flow effectively, and the collected data is saved directly in JSON which is impossible to used as a context for the next dialogue. Azure requires a lot of programming knowledge to create a survey chatbot. With the limited time and workforce, Azure is excessively complex to create the chatbot. Despite Manychat creating chatbots fast and easy, it is not programable.
Click and drag is what Manychat is all about. If a survey is changed/updated, the chatbot itself has to be updated manually. Narratory can perform the task which the project is asking for. It is easier to use, and able to integrate with many different channels through Dialogflow.
1
Twilio Autopilot. Accessed: 2020-05-08. https://www.twilio.com/docs/autopilot
2
Azure Bot. Accessed: 2020-05-08. https://azure.microsoft.com/sv-se/services/bot-service/
3.1 A chatbot that can interact with the respondent 9
3.1 A chatbot that can interact with the respondent
Fig. 3.3 Integration between Narratory and Facebook
After picking out the platform, the project will determine if the chatbot can comprehend human language. Narratory is an independent platform for building chatbots. Narratory focuses on research in the dialog system and takes a dialog script to model conversationsnote
3. As mentioned above, Narratory is using Dialogflow as its core which means Narratory’s NLP is entirely dependent on Dialogflow. Dialogflow is a development suite for producing conversational interfaces
4. It makes the chatbots conversation more human-like with the help of two concepts: Intents and Entities. To simplify, Intents refers to a user’s intentions when the user writes or says something. Dialogflow matches the user’s intentions to the best intent in an agent. An example of how to create Intents in Narratory A.4. Entities, to simplify, is a list of data that intents use to determine the user’s intention in a specific phrase. If an intent captures users’ attempts to order a meal then the entities should be a type of food and drink. For example when creating entities in Narratory A.3 and an intent using that entity A.5. Dialogflow can integrate with many chat channels such as Slack, Messenger, Skype, Kik... But the project will focus on Messenger as stated above in the Limitation. In order to integrate with Messenger, it requires a Facebook page and application.
Facebook pages have settings that allow an Facebook application to communicate with the users through Messenger. This application can set a webhook to Dialogflow to capture
3
Narratory. Accessed: 2020-05-08. https://narratory.io/docs/intro
4
Dialogflow. Accessed: 2020-05-08. https://dialogflow.com/docs
10 Method
the answer when Facebook users converse with the Facebook page. Webhook, a.k.a web callback, is a way to send data when a certain event triggers, which in this instance is referred to when the user answers the bot. Narratory has a webhook as well and it can be customized.
The customization depends on what the data will be used later on which will be explained in section 3.2.
Testing: When deploying a chatbot, it requires a certain level of language understanding to converse with the respondent. In order to test its understanding capability, the project will do a hypothesis testing to estimate it. Hypothesis testing is a statistical method that is used to assess the plausibility of a hypothesis by using sample data. There will be two tests: a test of proportion and a test of dependency.
To do the first test, it requires at least 100 sample data with the chatbot. The project will set a simple answer option from 1 to 5 as an entity together with examples for intents so the chatbot can understand to a significant level. The examples are some text written before the answer or the opposite. The project will assume the respondent will write a short text plus an answer to the chatbot. The answer is to guarantee correct, else the bot will never understand, but the short text is unknown. Due to the given examples in intents, the chatbot can understand the context to around fifty percent. This means the bot has a 25 percent chance to misunderstand the respondent’s answer. This will also be the test null hypothesis.
The alternative hypothesis is the chatbot misunderstanding is below 25 percent. The test will use the most common significance level, five percent. The significance level indicates the risk to reject a true hypothesis. The test function in this case is
U =
√ n(p − π
0)
p π
0(1 − π
0) (3.1)
where
n = total number of observations.
p = observed proportion among the observations.
π
0= proportion under the null hypothesis.
Using the test function (3.1) it can be checked to what extent the data supports the alternative hypothesis as opposed to the null hypothesis. To this end, the test function is asymptotically standard normally distributed. If the value u of the test function exceeds the standard normal percentile λ
αit is concluded that the null hypothesis should be rejected at the level α of significance and that the alternative should be accepted as true.
The chatbot’s NLU capability is based mostly on intents, entities. Intents are a must
for the chatbot to function properly but not entities. The project wants to know if entities
affect the chatbot language capability much. The test will include 20 tests without entity
3.2 Survey/Answer file and Application 11
and 10 tests with it. The null hypothesis: The chatbot’s NLU does not require an entity. The significance level is five percent. The alternative hypothesis: The chatbot’s NLU requires an entity.
Include Entity
Yes No
Understand
Yes N
11N
12R
1No N
21N
22R
2C
1C
2N
Test function in this case:
U = (N
11C
2− N
12C
1) √
√ N
C
1C
2R
1R
2(3.2)
where:
N
11− N
22= sample data divide into cases.
C
1= N
11+ N
21. C
2= N
12+ N
22. R
1= N
11+ N
12. R
1= N
21+ N
22.
N = Total number of observations.
Using the table, test functions (4.1) to calculate and then verify the hypothesizes above with standard normal distribution table. If |u| > λ
α /2it is concluded that the null hypothesis should be rejected at the level α of significance and that the alternative should be accepted as true.
3.2 Survey/Answer file and Application
Data extraction
The project uses a premade system by a company. In order for the premade system to use the answer from the respondent, it first needs to receive the data through an application, integrate it with the system, and convert it into the correct format that is analyzable in the system.
The application needs to be a Restful API to receive a POST method from the Narratory’s
webhook and will be coded in C# because the premade system uses C# as well. Before
building a Restful API, it will need to know how many parameters are needed to customize
the Narratory’s webhook. A.2 is an answer generated by the premade system. The answer
file shows a class type SurveyResult has four data type:
12 Method
• PublicationID: a GUID (globally unique identifier) to identify the survey
• PersonID: a GUID to identify a respondent. Identification allows the respondent only able to answer a survey once.
• Platform: platform of the premade system. Self-generated by the system.
• QuestionResult: a class that includes QuestionID, Timestamp (which is self-generated when creating the object), and an AnswerID.
Following the file format, the REST API needs at least four-parameters: PublicationID, PersonID, QuestionID, and an AnswerID. The premade system is built with Microsoft Visual Studio so the application does the same to avoid conflicts. The system has mainly two class libraries called Rundlg2 and Rundlg2.Integration. Rundlg2 consists of many classes:
• Repositories: classes providing a path to store/get data.
• Domain: classes with a constructor to create a new object with input parameters such as publicationID, personID, questionID...
Rundlg2.Integration library provides classes that use Domain classes from Rundlg2 and serialize them into XML format and put the output file according to the path provided by the Repositories class. The application uses these two libraries as references to convert the data from Narratory into the correct format. Setting the configuration is necessary for the application to use the class libraries. Using a template ASP.NET Web Application (.NET Framework) in Visual Studio to create a Web API application and create a controller for POST method to receive data from Narratory’s webhook.
Testing: The project uses a website called Hookbin to create a temporary website to test the webhook and receive the incoming data from the POST request. After receiving the data, it will be forward to the REST API through Postman. Postman is a program that can perform HTTP requests.
Survey converts into chat-bot dialog
To convert a survey into a chatbot dialog, it requires an understanding of the survey format and Narratory’s structure. Appendix A.1 is a survey example from the company which can be read through the premade system using Parser classes. The system will load the survey file into Survey classes which consists of the following information:
• PublicationID: an ID to identify the survey.
3.2 Survey/Answer file and Application 13
• LanguageID: an ID to identify the language using in the survey.
• Question class: a class consisting of the question ID, type, and answer options.
The Narratory’s chatbot is built on two main files called narrative and nlu. Narrative is a script to program the conversation flow and how the bot reacts to user expression while nlu is a script to create a list of intents and entities. Knowing the structure of the platform and system, the application can be simplified as a flow diagram:
Fig. 3.4 Application’s conversion
Narratory can set a customized webhook, mentioned above, so it is necessary to have PublicationID to identify the survey. The question class requires an languageID to get the text for the chatbot dialog. Since there are different type of questions, the application requires functions for each type to make a correct script.
Testing: Using the survey example mentioned above to test the application. After convert-
ing, update the bot and test the bot through Facebook Messenger or any other communication
channels.
Chapter 4 Result
Following the steps explained in the method. The project has created a Facebook page along with a Facebook app. Connect it together and put it up for testing different chatbot platform.
Narratory is able to connect to Messenger and able to converse with the respondent according to the test case in figure 3.2.
Fig. 4.1 Testing different chatbot platforms on Messenger
After successfully integrating the chatbot with Messenger, this research can now conduct experiments, observations to achieve results which will be shown below.
4.1 A chatbot that can interact with respondents
Can the chatbot understand the respondent’s answer?
In order to check whether it can be proved that the proportion of misunderstandings fall
below 25 percent, 100 observations, of answers to questions to the chatbot, were made. It
16 Result
turned out that 86 questions were correctly understood and the rest not. From this we may calculate the test function value
U =
√
√
100(0.14−0.25)0.25(1−0.25)
= −2.54
Comparison with normal-percentile table with significance level α = 0.05:
Because u = −2.54 < −1.64 = λ
0.05is true, the null hypothesis is rejected and the alternative hypothesis is proven to be true. Continue to find the p value with the help of standard distribution table (Z-table):
p = φ (α) = φ (−2.54) = 1 − φ (2.54) = 1 − 0.9945 = 0.0055.
The p value indicates the lowest significance level of our hypothesis is around 0.55 percent which means the chance to reject a true hypothesis is very low. The calculation proves the chatbot misunderstands respondent lower than 25 percent.
Continue with the second tests to verify if entities affects the chatbot’s NLU capability much.
Include Entity
Yes No
Understand
Yes 9 15 24
No 1 5 6
10 20 30
Calculation:
U =
(9∗20−15∗10)√√ 30
10∗20∗24∗6