Sentiment analysis on chatbot conversations (Understanding human-computer interaction)

Joshua Prabhakar
Ankercloud Engineering
5 min readSep 14, 2020

The recent advances in AI chatbots are making a measurable impact in the customer service industry. They have improved response times, user experiences, and reduced costs to businesses.

A recent Hubspot report states that,

92% of consumers say that they will stop purchasing from a company after 3 poor customer service experiences.

Chatbots are trained to understand brand-specific, as well as industry-specific knowledge and, are conversationally mature.

They have become emotionally intelligent and can interpret and understand sentiment and tone during an interaction to deliver the personalized user experience.

In this blog, we will see two different methods for logging conversations and evaluate the performance of the chatbot. And identify the method that is optimal for sentiment analysis on chat transcripts.

Sentiment Analysis

Sentiment analysis refers to the use of NLP (natural language processing) to interpret and classify text data as positive, negative, or neutral. This allows the chatbot to understand the customer’s emotions and adapt the conversation accordingly. Therefore sentimental analysis helps chatbot conversation to be personal and improves the overall user experience. The chatbot can also route the conversation to a human agent if there are signs of negativity or if there is a need for human intervention.

Image source: https://acquire.io

Amazon Lex and Amazon Comprehend

Amazon Lex gives you the ability to use sentiment analysis to enhance the conversation flow. Amazon Lex integrates with Amazon Comprehend to analyze user sentiment. The response from Comprehend contains the scores for each sentiment category.

AWS has made it easy to enable sentimental analysis in Lex with just a few clicks. AWS Comprehend can be enabled when a custom bot is created or in the setting of the AWS Lex Console.

Analyzing user satisfaction by performing sentiment Analysis using Amazon Comprehend.

The following architecture illustrates utilizing Amazon Comprehend for sentiment analysis from user inputs.

The user interacts with a chatbot that is hosted on a static website in S3. Amazon Lex captures the intents and inputs from the user and triggers a Lambda function.

The event passed to the Lambda function from the Lex contains the inputTranscript and all other metadata about the state of the conversation. We can specify the Lambda functions to log the conversation to the S3 bucket.

Another Lambda function downstream is triggered when the user conversations are logged to S3. This creates a batch job that feeds the chat logs to Amazon Comprehend.

Amazon Comprehend returns a field called sentimentResponse with other metadata. The sentimentResponse has two fields, SentimentLabel and SentimentScore. These two fields contain the result of sentiment analysis. An example of the response of Comprehend is shown below.

Using Amazon Lex Conversation logs and Amazon Comprehend to monitor and improve the chatbot interaction.

You can enable conversation logs to store bot interactions in S3. This architecture is similar to sentiment analysis architecture. We have used CloudWatch to create a log group and store the conversations of the chatbot. This makes it easy to log all the conversations to S3 rather than writing custom code using Lambda functions.

By using conversation logs you get a clear view of the conversations that users have with the bot. We can log the text input to Amazon CloudWatch Logs and audio input to Amazon S3. Adding to this the logs contain information about matched intent and missed utterances.

You can track the utterances matched to any configured intent and also the missed utterances help you to improve the chatbot design.

To enable conversation logs.

  1. Create a log group in Amazon CloudWatch.
  2. Create an IAM role with write permissions to CloudWatch Logs.
  3. On Amazon Lex Console choose your chatbot.
  • Go to Settings, choose conversation logs.
  • Choose the Log type, Log group, and the IAM role.
  • For audio logs, choose the S3 bucket, KMS key, and IAM role.

These logs can be viewed in the console of CloudWatch. It can be queried to see the Fallback intents. And also the fields of inputTranscript and botResponse can be viewed and analyzed.

These logs are stored in the S3 bucket and trigger a Lambda function to create a batch job and feed the conversation logs to Amazon Comprehend. The overall performance of the chatbot can be measured from the results of SentimentScore given by Comprehend.

So, from Conversation logs and Amazon Comprehend, we can analyze the performance of the chatbot and also determine customer satisfaction.

Conclusion

Artificial Intelligence has changed the way businesses support their customers. Using chatbot greatly reduces operational costs and time.

A chatbot cannot replace humans. But with the help of deep learning and NLP chatbots are becoming human-like. They have the potential to improve response time as well as understand customer queries and provide apt solutions.

Businesses lost 75% of customers due to waiting times.

-Retail Executive Survey.

Chatbots will soon be as normal as humans. Therefore, businesses must enhance their chatbot game and focus on improving customer satisfaction.

AWS simplifies the process of building chabot and analyzing user satisfaction. We as trusted AWS consulting partners help our customers develop chatbot solutions for business problems. To learn more, contact us at info@ankercloud.com.

--

--