Skill Level: Beginner


This tutorial will help you to integrate social media feeds to Watson IoT Platform and perform sentiment analysis on the tweeted content.


Hardware :

  • Any PC .


  • IBM Bluemix account.
  • Node-RED Application
  • Watson IoT Platform (WIoTP) service
  • Twitter account.

** Service fee may apply - Estimated Costs: Monthly Estimated Costs vary


  1. Introduction

    In this recipe, we will learn how to retrieve tweets happening on a particular topic and do a sentiment analysis using  the Node-RED application. After sentiment analysis, a sentiment score is assigned to every tweet and the score is sent to Watson platform for dash boarding 


  2. Setup Watson IoT Platform and Node-RED service on Bluemix

    Click on the Create Toolchain button provided below, to quickly deploy the Watson IoT Platform ‚Äď Node-RED Bluemix starter app. Post successful deployment, you shall have both the above mentioned services, up & running on Bluemix along with a Cloudant NoSQL DB at your disposal.


    Note: If you are a User using the United Kingdom Region in your Bluemix environment, then please make use of the steps mentioned in the IoT Recipe Deploy Internet of Things Platform Starter service on Bluemix to deploy the setup. Alternatively, you can also try using the Deploy to Bluemix button, to deploy the setup under your United Kingdom Region, provided your Jazzhub account is validated. Users of US South Region can ignore this step.


    Access the Node-RED application

    Access the Node-RED application by clicking on the View App option available, post deploying your application and then choosing the option Go to you Node-RED flow editor, to access the editor.

    Parallelly, you can also access the Node-RED editor directly by accessing the following URL


    The Node-RED Editor shall have a default flow, when you first access it. Click on the + sign to add a new page and continue to complete the steps mentioned in the subsequent sections of this recipe

  3. Create a Node-RED flow to send event to Watson IoT platform.



    The above Node-RED flow retrieve tweets on “IoT” topic and use “sentiment” node for sentiment analysis on the tweet content. The positive and negative sentiment scores are send separately on different topics to the platform as events. Note that, the Twitter node needs to be configured with your personal twitter handle and you need to authorize Node-RED to use the handle .Node-RED will guide you on this once you start configuring the “Twitter” node.

    ‚ÄúAcuumulate10tweets‚ÄĚ function node collects last ten tweets and send to the platform as a single event on a different topic.

    The Node-RED flow can be downloaded here . The events are sent to a registered device in Watson IoT platform.

    You can get information related to registering a device here . “IBM IoT” node should¬†be configured with¬†registered device information.

  4. Create cards in Watson IoT dashboard to visualize data sent as events to the platform.

    This section explains how we can visualize the sentiment scores as well as the tweet data in the platform. This is done by creating cards in Watson IoT¬†Platform which are configured to display real time data which arrives at the registered device as events.The cards are created ¬† under “Device-Centric Analytics” board .

    Section Realtime Data Visualization within the IoT Recipe Configuring the Cards in the new Watson IoT Dashboard explains how cards as well as real time graphs can be created. 

    • Settings for¬†Positive Sentiments card


    • Settings for Negative Sentiments card


    • Settings for Last Ten Tweets


    • Positive and Negative sentiments are displayed as shown below.


    • Last Ten Tweets ¬†are displayed as shown below.

  5. Conclusion

    Once cards are configured, we will be able to see live line graphs as well as last ten tweets. As and when the sentiment data as well as tweets reaches the platform the cards will get updated.

    We learned to retrieve the data from twitter handle, analyze it using sentiment node, send it as events to platform and display the data with the help of cards in dashboard view. Product owners can use this feature to get instant feedback about the performance of their products.

    Good Luck :-).

    As a next step, look at the list of analytical and cognitive recipes around Watson IoT Platform to analyze the IoT events.

Join The Discussion