For Day 3 of this series, I wanted to start diving into an application of Machine Learning. This has long been one of my favorite topics in Computer Science. For this post I wanted to touch upon Natural Language Processing. It’s a field of artificial intelligence (AI) that focuses on the ability for machines to manipulate Natural Language and derive meaning from it. It probably sounds badass because it is.


Sentiment Analysis with TextBlob

In particular I want to focus on Sentiment Analysis and mashing that up with Email. In this blog post I’m going to create a quick Python Flask application with the SendGrid Parse Webhook and a Python Lib called TextBlob ( that will get the sentiment of every incoming email and respond back accordingly.

You can imagine if this email address were to be the first responder when a customer emails in for support on your current product. It could email back a different, unique response if the message is positive or negative.


  • SendGrid account to get incoming & send outgoing emails with your app  (
  • SendGrid Python Lib
    • $ pip install sendgrid
  • Flask:
    • $ pip install flask
  • Textblob:
    • $ pip install -U textblob
    • $ python -m textblob.download_corpora

Sample Code:

In Action

Below are two images of the above code in action. The first image shows the scenario of a happy customer and the second of a fictitious upset customer.


Over the next few weeks, I’m going to continue writing about different technologies, so check back every Monday, Wednesday, and Friday for new tech posts! You can also visit my intro post that will have an updated list of everything I’ve written.

Expert advice and insight about all things email including best practices tips, examples, and advice for marketers, developers, and everyone in between.