Dweet the tone and sentiment of a Tweet!

This flow provides an example of how you can use IBM Watson API for "tone" analysis of text.

  1. The flow starts with the Twitter node, in the provided example it is looking for #IBM.

  2. The text of the tweet is passed through both the "sentiment" node, and "tone analyser v3" node (an IBM Watson Service).

  3. The payload is then formatted to contain the original text, and the results from the tone and sentiment analysis.

  4. This payload if then sent to a thing (see https://Dweet.io).

I have have used a "sparkline" in https://Freeboard.io to show the trend...

[{"id":"b974ae45.468b5","type":"debug","z":"c53129c.f3aced8","name":"","active":false,"console":"false","complete":"payload.text","x":618,"y":269,"wires":[]},{"id":"5726f1d4.a8d91","type":"http request","z":"c53129c.f3aced8","name":"POST the formated URL to Dweet.io","method":"POST","ret":"txt","url":"","tls":"","x":252,"y":449,"wires":[["9f2eafed.60d15"]]},{"id":"8d862e7b.7279d","type":"twitter in","z":"c53129c.f3aced8","twitter":"","tags":"#IBM","user":"false","name":"Get #IBM tweets","topic":"tweets","x":126,"y":148,"wires":[["86069e40.79f96"]]},{"id":"57b39356.a84c6c","type":"debug","z":"c53129c.f3aced8","name":"","active":false,"console":"false","complete":"payload.tone","x":617,"y":312,"wires":[]},{"id":"1441f0d9.ebbe0f","type":"watson-tone-analyzer-v3","z":"c53129c.f3aced8","name":"Get the \"tone\" of the tweet","tones":"all","sentences":"true","contentType":"false","x":223,"y":269,"wires":[["82ee8ff8.7d117"]]},{"id":"86069e40.79f96","type":"sentiment","z":"c53129c.f3aced8","name":"Get the \"sentiment\" of the tweet","x":233,"y":210,"wires":[["1441f0d9.ebbe0f"]]},{"id":"82ee8ff8.7d117","type":"function","z":"c53129c.f3aced8","name":"Format the payload...","func":"msg.payload = {\n    \n    \"text\" : msg.payload,\n    \"tone\" : msg.response,\n    \"sentiment\" : msg.sentiment\n};\n\nreturn msg;","outputs":1,"noerr":0,"x":204,"y":330,"wires":[["b974ae45.468b5","57b39356.a84c6c","e78fe96a.187018","28923775.d76dc8"]]},{"id":"e78fe96a.187018","type":"debug","z":"c53129c.f3aced8","name":"","active":false,"console":"false","complete":"payload.sentiment","x":635,"y":359,"wires":[]},{"id":"28923775.d76dc8","type":"function","z":"c53129c.f3aced8","name":"EDIT: Add your \"thing\" and \"key\"...","func":"msg.thing = \"my-thing-uniqueid\";\n//msg.key = \"my-thing-key\";\n\nmsg.type = \"POST\";\n\nif(msg.key)\n{\n  msg.url = \"https://dweet.io:443/dweet/for/\" + msg.thing + \"?key=\" + msg.key;\n}\nelse\n{\n  msg.url = \"https://dweet.io:443/dweet/for/\" + msg.thing;\n} // endif\n\nmsg.headers = {\"Content-Type\" : \"application/json\"};\n\nreturn msg;","outputs":1,"noerr":0,"x":243,"y":390,"wires":[["5726f1d4.a8d91"]]},{"id":"9f2eafed.60d15","type":"debug","z":"c53129c.f3aced8","name":"","active":true,"console":"false","complete":"statusCode","x":605,"y":449,"wires":[]},{"id":"b6d5d676.492a28","type":"comment","z":"c53129c.f3aced8","name":"Get tweets containing #IBM then dweet them!","info":"\n1) Get a tweet containing #IBM\n\n2) Dweet the tweet...","x":216,"y":101,"wires":[]}]

Flow Info

Created 8 years, 4 months ago
Rating: not yet rated

Actions

Rate:

Node Types

Core
  • comment (x1)
  • debug (x4)
  • function (x2)
  • http request (x1)
Other

Tags

  • Twitter
  • Dweet
  • Watson
  • Tone
  • Sentiment
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option