JeanCarl's Adventures

Analyzing text messages via the Tone Analyzer service

May 25, 2016 |

I’m at the Twilio SIGNAL conference with an update to Tone LED Pin demo. If you recall, I analyzed tweets from Twitter around a hashtag or search term and took the most prevalent social tone from IBM Watson’s Tone Analyzer service to graph per minute stats on an NeoPixel LED ring. Yes, it is still a glorious wearable pie chart.

Taking advantage of the super simple to use Twilio service, I connected a phone number that takes in text messages and process those instead of tweets. The changes to my application were also pretty simple, removing one node and adding three nodes. Here’s how I modified my application to use Twilio. If you haven’t deployed the application, you find the instructions on a previous blog post.

First, let’s setup an HTTP endpoint in the Node-RED application instead of the Twitter node. Delete the Twitter node. Add a HTTP endpoint to expose the processing flow to the URL /twiliocallback.

Photo

Add a change node to move some data around. The first rule preserves the text message info in the msg.text property, useful if you want to respond back to the phone number the message comes from. The second rule sets the msg.payload property to the body of the text message, which is used by the Tone Analyzer node.

Photo

Finally, add a HTTP response node, and connect the nodes together as shown below.

Photo

Click on Deploy in the top right corner. That’s it for the application. All that’s left is to get a phone number from Twilio and instruct Twilio where to send the text messages to.

Register for a Twilio account and create a new phone number. You can take a little creative time to find that really awesome phone number using their search tool.

On the settings page for your new Twilio number, set the messaging webhook to point to your Node-RED application’s HTTP endpoint.

Photo

Send a text message to the Twilio phone number and see the results from the IBM Watson Tone Analyzer service included in the graphs and on the connected LED Pin.