Email Sentiment Analysis in 20 minutes

Guide on how to do sentiment analysis on emails and exclude things like the email signature and handle reply chains.


Integromat Example Image

Email bodies contain a wealth of data about a business and unlocking all of that potential value gets easier all the time. One way is to use sentiment analysis and feature detection.

In this guide we’ll:

  1. Explain what sentiment analysis is
  2. Cover common challenges
  3. Setup a cheap and easy sentiment analysis flow for email in 20 minutes

What is Sentiment Analysis and Feature Extraction

Sentiment analysis is a machine learning tool which can read normal human conversation and understand the mood of the piece. For example, if someone says “I hate this product” then the sentiment is negative. If someone says “I love this product” the sentiment is positive. A good sentiment analysis engine can understand and tag these two sets of text correctly and even much more complex sets of text like an email message, support conversation and more.

Entity extraction is the process of extracting unique bits of information from a message. For example, if “John Smith” appears in a message, an entity extractor algorithm could understand that is a name of a person and tell you where in the text that name appears. Other examples are phone numbers, locations and dates.

There are many services and libraries that exist to handle sentiment analysis. Some are cloud based APIs you can just call with some text and others like ML.NET let you train a learning model.

Problems with Emails for Sentiment Analysis

The biggest challenge to processing emails for sentiment analysis is extracting only the parts of the email body with real, meaningful value.

SigParser is able to help developers with sentiment analysis on emails in three ways.

Problem 1: Email Signature Removal

For example, you don’t want to send the email signature for a contact to your sentiment analyzer.

Problem 2: Reply Chain Splitting

You don’t want to process the reply headers.

On June 1st, 2015 John Smith wrote:

This has no value to your sentiment analysis. Additionally, below that is probably another email. You need to make sure the sentiment in that email doesn’t get assigned to the wrong person.

Problem 3: Convert HTML to Text

If an email arrived as HTML, you’ll want to convert it to text. Often times the text preview isn’t very good or is missing so something like SigParser can convert the HTML into a text form.

Problem 4: Exclude Marketing Emails

Sentiment analysis services tend to be somewhat expensive. SigParser can tell you if the email is likely a marketing type email or a real human type email. You don’t want to run sentiment analysis on non-human type/marketing emails.

Email Sentiment Analysis in 20 minutes

Integromat Example Image

This is probably the fastest, easiest way to get going with sentiment analysis and entity extraction for emails and get the results into the software you already use like your CRM or a spreadsheet.

We’ll be setting up the following:

  1. Integromat for monitoring email
  2. SigParser for splitting emails
  3. ParallelDots for sentiment analysis
  4. Output the results to a Google Sheet but you could have any CRM as an output if you wanted

Integromat

Create an Integromat account. Integromat is a no-code API connector service. They have many predefined APIs like SigParser and Gmail and Office 365 and they also let you connect to custom APIs. You don’t have to be a technical wizard to use this.

SigParser API Key Admin Screen ### SigParser

Create an account with SigParser and generate a free API key. You’ll get 500 API requests for 30 days to test with. You’ll use this in Integromat.

ParallelDots

Signup for a free ParallelDots. At the time of this writing if you create an account you get 1000 API requests per month for free.


Step 1: Setup a new scenario in Integromat

Inside Integromat click Scenarios and click Create a new scenario

Select Email, SigParser and HTTP connectors and then click Continue.

You’ll see a single empty connector now.

Integromat Email Connector

Step 2: Setup Email Connector

Select Email for the connector type and then the Trigger Watch emails and configure it to pull email from your email server.

Configure it however you need for fetching the email from your email server.


Integromat SigParser Connection Example

Step 3: Setup SigParser

SigParser is an email body parsing tool. It takes an unstructured email and can do things like split all the emails into their reply chains for example.

In the scenario, click the little half circle on the right side of the Email connector.

Select SigParser for the operator type and then select the action Parse Email

Configure each of the fields to map the email fields into the SigParser input fields.

Be sure to map both the Plain Text and HTML Content fields for the email. This is important as some emails contain both.
Integromat HTTP Connector Example

Step 4: Setup ParallelDots HTTP Connector

ParalleleDots is a cloud based AI as a service. You give it text, images or video and it can give you back structured information. In this case we’ll be giving it email message bodies and getting back sentiment.

ParallelDots doesn’t have a ready made integration with Integromat but that’s not a problem. We’ll just call their API with the HTTP module.

Add a connector for the HTTP module and add the action Make Request.

Configure it just like pictured. Be sure to get the API key from the ParallelDots website.

Notice the field Body without Signature Plain Text we’re using from SigParser. This field contains only the body part of the first message in the email. If the email message has a signature, that is stripped off along with the “Thanks” or “Have a good day” ending line. Also, if the email body contained the original replies down below those have been removed.


Integromat JSON Example Image

JSON Transform Results

You’ll need to add a JSON operator to transform the raw text output from the API to something usable.

Add the JSON operator to Parse JSON and map it like picture.

Then run the flow by clicking “Run Once” at the bottom left. This will run the flow and if everything works then the data model will be available to use in the next step.


Integromat Google Sheets Example Image

Step 5: Output to Something

For this step we’ll output the results to a Google Sheets. For you though, you could send the results anywhere. For example, you could send them to custom fields in your CRM.

Setup a Google Sheet first in Google Sheets with columns like in the final picture below.

Add the Google Sheets operator to SigParser and map the fields like so.

Click Run Once to validate your setup works and check the Google Sheet for results.

Here is what the final Google Sheet looks like.

Integromat Example Google Sheet Screenshot

Next Steps

Don’t Analyze Marketing Emails

You could add a filter between the SigParser operator and ParallelDots to filter out any spammny looking messages. SigParser exposes a property which indicates this for each email message. This is good for reducing your sentiment analysis API calls.

Entity Extraction

ParallelDots has an almost identicial API for entity extraction. They have APIs for keyword extraction, classifying the documents, find intent and potential abuse in emails or extracting phrases.

Try SigParser for FREE

Try SigParser for FREE with no commitment. Schedule a 15 minute web conference to get an overiew of SigParser and set up with a free trial account. No commitment required.