Smart Digital Content Platform

How to apply sentiment analysis to incoming emails in Athento?

Optimize customer satisfaction with Athento: apply sentiment analysis to emails automatically, assign states based on happiness­čö« #AthentoMagic
Análisis del sentimiento / Sentiment Analysis
Iván Cárdenas

Iván Cárdenas

In this article, we’re going to explain step by step how you can apply sentiment analysis to emails that are received directly in Athento and automatically assign a lifecycle status that corresponds to a positive (satisfied customer), negative (dissatisfied customer) or neutral (neutral customer) sentiment analysis.

For this tutorial, we are going to assume that what we are receiving are customer service emails, so we will use AI to know if customers are happy, unhappy or neutral emails, automatically.

Análisis del sentimiento / Sentiment Analysis

Presettings

The first thing you will need is a space. This is where you will receive your emails. See how to create a space in Athento.

Análisis del sentimiento / Sentiment Analysis

You will also need a form to store your emails. Create one with a Text Area field, called for example Email Body.

Análisis del sentimiento / Sentiment Analysis

If you have never done these basic configurations in Athento, here you have the documentation:

Great! We almost have our pre-configurations ready.

We are also going to need a lifecycle that has 3 states:

  • Satisfied customer.
  • Dissatisfied customer.
  • Neutral customer.

There is no need to create transitions between these, as Athento itself will make the transition according to the sentiment analysis.

As initial state you can set Unknown, which will be the state that the emails will take when they enter the platform.

Análisis del sentimiento / Sentiment Analysis

You must activate the lifecycle for us to use it.
Here you have the documentation for the lifecycle configuration:

Step 1: Integrate the email account in Athento

It is possible to connect a mailbox with an Athento space. This integration will be done from the space administration, in the Integrations tab. From there you will be able to connect the space with the mailbox, for this tutorial, we connect a pop3 mailbox.

Análisis del sentimiento / Sentiment Analysis

You can consult the documentation on how to link a space and a mailbox from here.

In the space configuration, you must activate the uploading of documents and their processing.

Análisis del sentimiento / Sentiment Analysis

Great! Now we need an extra configuration to make sure that every X amount of time, Athento reads the emails that arrive to the account. This is done with an Athento command for uploading emails. You must enable this command in the instance in case it is not already enabled.

It is the command load_mails.

Análisis del sentimiento / Sentiment Analysis

You can also take advantage of this and activate the crontab that is in charge of automatically processing the documents that enter your space (the crontab that appears just above the one for uploading emails).

If you are not familiar with the activation and execution of programmatic tasks, here is the documentation:

After the completion of this step, the emails should be entering your space.

Step 2: Set up the operations required to process the mails

You must install the following operations in space:

  • Op_analyze_documents_sentiment_v1 or┬áAnalyze document sentiment: this is the operation that performs sentiment analysis.
  • Op_lifecycle_transition_v2 or┬áLife cycle transition: you have to install this operation 3 times. One for each analysis status (Positive, Negative, Neutral).
  • Extract text V2 and Extract metadata fast:these two we need to take the text of the email and pass it to the text area field that we created in the presets.

The automatisms of the space have to be configured like this:

 

Análisis del sentimiento / Sentiment Analysis
Análisis del sentimiento / Sentiment Analysis

About the sentiment analysis operation

This operation uses a HugginFace model. Athento offers integration with HugginFace so you can use these AI models.

The model used by this operation is cardiffnlp/twitter-roberta-base-sentiment-latest.
This model was trained on over 100 million tweets.

This operation, once executed on a text, will return a feature or characteristic of the sentiment_analysis document with the value: positive, negative or neutral.

Análisis del sentimiento / Sentiment Analysis

At the moment, no configuration is required at the parameter level for the operations you have installed.

Step 3: copy the text of the mail into the text area field

At present, the operation Op_analyze_document_sentiment_v1 works on the content of the text fields of a document. Therefore, we need the mail text to travel to the text area field we create.

We can do this with a dynamic expression in the configuration of this field:

fil.gmv("feature.text")

This dynamic expression will allow you to copy the value of the email text to the text area field.

Análisis del sentimiento / Sentiment Analysis

Great! Now that you have this, you can run the operation manually on any of the emails that have already entered your space.

Step 4: condition operations that automatically change the life cycle

The purpose of these 3 operations that we have activated is to set the lifecycle state according to the evaluation of the sentiment analysis operation. What we will do is to configure each of the operations to move to one of the 3 lifecycle states, but we will condition its execution to match the sentiment analysis.

For example, we will configure the one that moves to SatisfiedCustomer. In Final state we will put SatisfiedCustomer and check the box to force the change.

Análisis del sentimiento / Sentiment Analysis

Then, from the advanced administration in the operation we are working with, we look for the condition field and set the following condition.

fil.gfv("sentiment_analysis") == "positive"

Análisis del sentimiento / Sentiment Analysis

What this expression does is that it retrieves the value of the sentiment_analysis feature and compares it with the string “positive”. If there is a match, Athento will allow the status change to SatisfiedCustomer because the result of the sentiment analysis of the mail was positive.

We repeat this same process with the other two operations:

The one that moves to DissatisfiedCustomer we condition on the sentiment analysis result being “negative”.
The one that moves to Neutral, we make it conditional on the sentiment analysis result being “neutral”.

Step 5: Let’s try it!

Voilà! All the configurations are ready. Now you just need to send emails and check that everything runs correctly.

And so that you have something quick to test with, here is the text of two test emails.

Let us know what you thought of this tutorial and suggest new tutorials to help you implement new configurations!

Email 1

Subject: Very disappointing customer service
Dear Acme team,

On the 17th of October, I purchased a tablet Samsung Galaxy XT600 from your store for 500ÔéČ.

I am not satisfied with the product because it has not performed as it should. It is frequently shutting down. The screen goes black and I can’t do anything.

I have tried to communicate with your team via phone. Nobody answers the phone at your shop. It seems like I am alone with my problem.

I need a prompt response from your team. Either you reimburse me or change the product.

If I don’t receive an answer from you in the following 2 business days, I will leave a review for everyone to see on Google. I don’t want someone else to go through all of this trouble.

I am very frustrated and unhappy with your service.

Yours sincerely,
Veronica Meza.

 

Email 2

Subject: Incredible customer service

Dear Acme team,

I just want to congratulate you for the amazing customer service you provide. Yesterday in the shop in 5th Av. one of your employees, John Doe, made sure I received all the possible help. He really explained to me the advantages of the product I was interested in and helped me compare it with others.

He was kind and respectful.

I really want to make sure the managers of the 5th Av. shop know what amazing customer service their employees are delivering.

Thank you very much,
Ivan Cardenas.