Using Bandwidth’s Messaging API and Watson’s Tone Analyzer API to Analyze the Tone of Text Messages

Person using mobile phone to detect tone

As technology has evolved over the years, we’ve developed more non-verbal means of communication in our social and professional environments. Emails, text messages, Facebook messages, Instagram DMs, Slack messages, news articles, and blog posts are just a few examples of types of nonverbal communication.

With our fast-paced lives, these means of communication are more convenient. Want to make dinner plans with a friend later in the week? Send them a text and they can respond whenever is most convenient with no hassle trying to find time  time for a phone call. Communicating this way is also convenient for working with people in different time zones, since it’s much easier to respond to an email than trying to schedule a phone call with someone across the globe.

But there’s an inherent problem with non-verbal communication. There’s no tone of voice!

Since tone of voice is much more difficult to portray through written text than through human voice, it’s very possible the sentiment behind your email, text, or Facebook message might get misconstrued., The person on the other side might take your message in a negative manner.

So how do we solve this problem?

Using Bandwidth’s messaging API and Watson’s Tone Analyzer API, we can set up a server that intercepts a user’s text messages, analyzes them, and returns a sentiment analysis to the user. The user can then decide to send the initial message to its intended recipient or cancel the message so they can rewrite it. Ultimately, this allows you to see how someone else would interpret your message before it’s sent.

How the “Checking SMS for Tone” App Works

User 1 has phone number 828-111-2222.

User 2 has phone number 828-333-4444.

User 1 wants to send a message to User 2, but wants to make sure they interpret the message correctly.

User 1 sends their message to the Bandwidth number 828-202-3239 in the following format:

“+18283334444 <message>”

The Bandwidth number points to a Bandwidth application that makes a POST request on an AWS server. When this server receives a POST request from a new number, the message is sent to the Watson Tone Analyzer to be analyzed. The analysis is sent back to the initial user, and the destination and message of the initial text are temporarily stored on the server.

User 1 will receive a reply from 828-202-3239 with the analysis of their message from the Watson Tone Analyzer, and will be asked to continue with sending their message. If they reply ‘yes’, the server will catch this response and send the message to User 2, and User 2 will receive a text from 828-202-3239 in the following format:

“Message from +18281112222: <message>”

If User 1 replies ‘no’, the destination and message of the initial text are removed from the server.

Anonymous Text Therapy

Let’s take this idea one step further and discuss how to implement an app that would allow a user to receive anonymous therapy along with message tone analysis through text messages.

A patient can sign up for this “therapy service” using their phone number and receive a Bandwidth phone number to text. Simultaneously, this same Bandwidth phone number would be assigned to a therapist, acting as a mask between the patient and therapist that allows them to communicate without sharing their phone numbers. Each time the patient and therapist text through the Bandwidth phone number, they receive a reply containing the tone analysis of their message and must confirm the sending of their initial message.

Diagram showing how Toner works
How Toner Works

Everyone knows the importance of communication, but not everyone may know how important it is to make sure what you’re communicating is interpreted correctly. The human element of communication is less pronounced in nonverbal communication, and it’s easy for you to interpret text differently than someone else. Miscommunication can hurt relationships and business deals, and we should always take extra steps to make sure our communication is correct.