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.
Start Coding
DT API Account
To complete this tutorial, you will need a DT API account. If you don’t have one already, you can sign up today and start building with free credit. Once you have an account, you can find your API Key and API Secret at the top of the DT API Dashboard.
This tutorial also uses a virtual phone number. To purchase one, go to Numbers > Buy Numbers and search for one that meets your needs.
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 Vonage 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.
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.
Kelly J Andrews is a developer advocate for Nexmo and has been tinkering with computers for over 30 years, using BASIC for the first time at the age of 5.
It wasn't until building his first webpage in 1997, and trying out JavaScript for the first time that he found a true calling. Kelly now fights for JavaScript, testable code, and fast delivery.
You can find him singing karaoke, performing magic, or cheering for the Cubs and Fighting Irish.