Tweet Tone

Perform Tone analysis of Tweets using the Watson Tone Analyzer service

This flow is similar to Sentiment Flow but instead of using Sentiment we will be using Tone Analyzer Service to analyze the tone of the tweet and whether or not it expresses Joy, Fear, Sadness, Anger or Disgust

How to build this flow

Step 1: Copy Tweet Simple

Copy the flow from Tweet Simple and paste nodes into this new project

Step 2 : Insert Analyze Tone Service Node

Insert Analyze Tone Node from IBM Watson palette and connect to output of function node

Get Access to Tone Analyzer

  • Log into IBM Cloud and Go to IBM Cloud Catalog

  • Search for Tone Analyzer Service within Catalog

  • Create Lite Service

  • Go to created Service and get service credentials for Tone Analyzer

  • Set up node properties with username , password and API key from service credentials

Step 3. Insert Tone Categories , High Score Function and Debug Messages

  1. Insert Change Node and name node tone_categories . Change msg.payload to msg.response.document_tone.tone_categories . Connect node to Tone Analyzer service

  1. Insert function node and name node High Score . Connect Node to Tone Analyzer Service and add the code below to filter out emotions from Tone analyzer service and give a score value .

  1. Insert Debug Nodes

  2. 1 debug node called Print msg.response with property msg.response . This node is connected to tone analyzer

  3. 1 debug node called Tone categories with property msg.payload. This node is connected to tone categories

  4. 1 debug node called Score with property msg.topic . This node is connected to High Score function

Step 4. Insert Switch node and various emotions

Insert the switch node from the palette and name it Select Emotions

Set property to msg.topic and connect node to High Score output

Add 5 properties :

  • ==Joy

  • == Sadness

  • == Fear

  • == Anger

  • == Disgust

Connect Switch node to Change node for each topic and connect Change Node to Template node with property msg.payload

Insert Change Node to Debug node to print output panel

Step 5 : Deploy

Once this flow is deployed you should be able to see whether a tweet expresses Joy, Fear , Sadness , Anger or Disgust !

Flow can be imported from :

Last updated

Was this helpful?