Adding Sentiment Analysis to SMS with IBM Watson

Adding Sentiment Analysis to SMS with IBM Watson

Published April 04, 2019 by Kelly J Andrews

When it comes to communications via SMS, I think we all can agree that sometimes the sender’s intent can be misinterpreted. I know that, personally, meaning and context around words can easily be misunderstood.

In whatever way technology contributes to this ongoing difficulty, technology also helps bail us out with sentiment analysis tools. In this case, we are going to connect Nexmo SMS Messaging with the IBM Watson Tone Analyzer.

What is IBM Watson Tone Analyzer?

The IBM Watson Tone Analyzer is an API that allows text to be understood as emotions and communication style.

This set of APIs allows developers to listen to social channels, monitor customer support and integrate with chatbots. Doing so allows teams to build strategies around customer satisfaction or frustration.

Watson Sentiment Analysis Graphic

Start Coding

In order to begin sentiment analysis, you will need to setup the IBM Tone Analyzer service on IBM Cloud. Turning on this service will give your application the credentials needed to run the app.

The repository for the sample application is on Github. The full repo will allow you to deploy to Heroku, IBM Cloud, run locally as a Docker container, or remix on Glitch.

The quickest way to get going is to remix on Glitch and update your environment variables. Check out the readme on directions to get a new virtual number using the Nexmo CLI or using the dashboard.

What’s Happening

The overall purpose of the repo is to show you how simple it is to connect Nexmo SMS with IBM Watson Tone Analyzer.

The virtual number, when configured, will call the /message route for any incoming SMS message to that number. This route, in turn, calls the toneAnalyzer.tone method from the IBM Watson package sending the SMS text to be analyzed.

Command Line Analysis

While these are arbitrary examples, you can begin to see the power behind something like this.

What’s Next?

Where do you go from here? The application only displays the response in the logs. Ideally, you would create an application that would display the sentiment either as text or perhaps even as emoticons.

You can build this into an event notification system for real-time analysis for live SMS chat analysis or monitor chatbot activity for potential intervention with humans.

Leave a Reply

Your email address will not be published.

Get the latest posts from Nexmo’s next-generation communications blog delivered to your inbox.

By signing up to our communications blog, you accept our privacy policy , which sets out how we use your data and the rights you have in respect of your data. You can opt out of receiving our updates by clicking the unsubscribe link in the email or by emailing us at