> For the complete documentation index, see [llms.txt](https://nodered-dashboards.gitbook.io/node-red-dashboards/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://nodered-dashboards.gitbook.io/node-red-dashboards/workshop/tweet-dashboard-example.md).

# Tweet Dashboard Example

## About this flow&#x20;

In this flow you can visualize the sentiment score of tweets :&#x20;

![](/files/-LlmrP4hhm2FGa4VifPX)

![](/files/-LlmrRk9FQVk4rl8ydwI)

In this flow you will need to configure your twitter API Credentials&#x20;

### Steps to Configure Twitter : &#x20;

The Twitter input node needs an active Twitter ID to gather tweets as data input&#x20;

Double click on the twitter node when you insert it into node red and you will see something like this :&#x20;

![](/files/-Lm7t5v5RO0FsXzlMOf4)

To set up a new twitter ID click on the pencil button on the side of Twitter ID&#x20;

![](/files/-Lm7tBUFsNiGHwJQDF5_)

You will need an active twitter account and the API Key, API secret key , Access token and Access token secret to set up your account&#x20;

### Go to : [How to create a Twitter application](https://docs.inboundnow.com/guide/create-twitter-application/) to get your keys for Twitter node&#x20;

Once you have your keys from your twitter app you can add the associated info into the Twitter input node!

### Import flow from here :&#x20;

```
[
   {
      "id":"f2ce3087.ee968",
      "type":"tab",
      "label":"Tweet Language ",
      "disabled":false,
      "info":""
   },
   {
      "id":"3b13170a.8b5ba8",
      "type":"inject",
      "z":"f2ce3087.ee968",
      "name":"Happy test",
      "topic":"",
      "payload":"{\"text\":\"every one is awesome\"}",
      "payloadType":"json",
      "repeat":"",
      "crontab":"",
      "once":false,
      "onceDelay":"",
      "x":160,
      "y":140,
      "wires":[
         [
            "1ccd705b.07ca2"
         ]
      ]
   },
   {
      "id":"1ccd705b.07ca2",
      "type":"change",
      "z":"f2ce3087.ee968",
      "name":"",
      "rules":[
         {
            "t":"set",
            "p":"tweet",
            "pt":"msg",
            "to":"payload",
            "tot":"msg"
         }
      ],
      "action":"",
      "property":"",
      "from":"",
      "to":"",
      "reg":false,
      "x":380,
      "y":180,
      "wires":[
         [
            "19037133.924c87"
         ]
      ]
   },
   {
      "id":"62a9afb1.aa101",
      "type":"inject",
      "z":"f2ce3087.ee968",
      "name":"Sadness test",
      "topic":"",
      "payload":"{\"text\":\"This is miserable and sad\"}",
      "payloadType":"json",
      "repeat":"",
      "crontab":"",
      "once":false,
      "onceDelay":"",
      "x":170,
      "y":200,
      "wires":[
         [
            "1ccd705b.07ca2"
         ]
      ]
   },
   {
      "id":"60cfb004.afcc18",
      "type":"inject",
      "z":"f2ce3087.ee968",
      "name":"Angry test",
      "topic":"",
      "payload":"{\"text\":\"I hate this demo\"}",
      "payloadType":"json",
      "repeat":"",
      "crontab":"",
      "once":false,
      "x":180,
      "y":260,
      "wires":[
         [
            "1ccd705b.07ca2"
         ]
      ]
   },
   {
      "id":"e87cc8f9.0d3b1",
      "type":"watson-text-to-speech",
      "z":"f2ce3087.ee968",
      "name":"text to speech",
      "lang":"en-US",
      "langhidden":"en-US",
      "langcustom":"NoCustomisationSetting",
      "langcustomhidden":"",
      "voice":"en-US_AllisonVoice",
      "voicehidden":"es-ES_EnriqueVoice",
      "format":"audio/wav",
      "password":"Go3dEL-Escher-B@ch-climB-0ak5!",
      "apikey":"YptiEGxP7PZK71dQVZq96jBmZZ7Y9KxJcDwYO9Kt5WWp",
      "payload-response":false,
      "default-endpoint":true,
      "service-endpoint":"https://stream.watsonplatform.net/text-to-speech/api",
      "x":840,
      "y":380,
      "wires":[
         [
            "2b50d466.c015dc"
         ]
      ]
   },
   {
      "id":"19037133.924c87",
      "type":"function",
      "z":"f2ce3087.ee968",
      "name":"Remove URLS and replace #",
      "func":"var tweet = msg.tweet.text;\nvar newtweet = tweet.replace(/#/g, \" Hash tag \");\n\n// regex from https://stackoverflow.com/questions/1500260/detect-urls-in-text-with-javascript\nmsg.payload = newtweet.replace( /(([a-z]+:\\/\\/)?(([a-z0-9\\-]+\\.)+([a-z]{2}|biz|com|co|edu|gov|info|net|org|ly))(:[0-9]{1,5})?(\\/[a-z0-9_\\-\\.~]+)*(\\/([a-z0-9_\\-\\.]*)(\\?[a-z0-9+_\\-\\.%=&amp;]*)?)?(#[a-zA-Z0-9!$&'()*+.=-_~:@/?]*)?)(\\s+|$)/gi, \"see short URL \" );\nreturn msg;",
      "outputs":1,
      "noerr":0,
      "x":640,
      "y":160,
      "wires":[
         [
            "7e5ec0f9.bbb5a8",
            "37cf1c8a.bf4d54"
         ]
      ]
   },
   {
      "id":"7e5ec0f9.bbb5a8",
      "type":"debug",
      "z":"f2ce3087.ee968",
      "name":"",
      "active":true,
      "tosidebar":true,
      "console":false,
      "tostatus":false,
      "complete":"false",
      "x":870,
      "y":140,
      "wires":[

      ]
   },
   {
      "id":"dffc23d5.a9663",
      "type":"debug",
      "z":"f2ce3087.ee968",
      "name":"Tone categories",
      "active":true,
      "console":"false",
      "complete":"payload",
      "x":880,
      "y":320,
      "wires":[

      ]
   },
   {
      "id":"9a0f3aa8.923ad",
      "type":"function",
      "z":"f2ce3087.ee968",
      "name":"High Score",
      "func":"var emotions = [];\nemotions = msg.response.document_tone.tone_categories\n                .filter(function(c){\n                    if (c.category_id == \"emotion_tone\")\n                    {return c; }\n                    })[0].tones;\n                    \nvar myscore =  0;\nfor (var i=0; i<emotions.length; i++) {\n    if(emotions[i].score > myscore) {\n        msg.payload = emotions[i].score;\n        msg.topic = emotions[i].tone_name;\n        myscore = emotions[i].score;\n    }\n}\n\nreturn msg;",
      "outputs":1,
      "noerr":0,
      "x":170,
      "y":360,
      "wires":[
         [
            "16df6bd0.9e3004",
            "1f4d73c0.0f3c14"
         ]
      ]
   },
   {
      "id":"16df6bd0.9e3004",
      "type":"debug",
      "z":"f2ce3087.ee968",
      "name":"Score",
      "active":true,
      "console":"false",
      "complete":"topic",
      "x":370,
      "y":360,
      "wires":[

      ]
   },
   {
      "id":"677da65d.953ad8",
      "type":"debug",
      "z":"f2ce3087.ee968",
      "name":"Print msg.response",
      "active":true,
      "console":"false",
      "complete":"response",
      "x":630,
      "y":260,
      "wires":[

      ]
   },
   {
      "id":"37cf1c8a.bf4d54",
      "type":"watson-tone-analyzer-v3",
      "z":"f2ce3087.ee968",
      "name":"Analyze Tone",
      "tones":"emotion",
      "sentences":"true",
      "contentType":"false",
      "tone-method":"generalTone",
      "interface-version":"2016-05-19",
      "default-endpoint":true,
      "service-endpoint":"",
      "x":390,
      "y":280,
      "wires":[
         [
            "9a0f3aa8.923ad",
            "677da65d.953ad8",
            "1d5a2d93.b33b62"
         ]
      ]
   },
   {
      "id":"1d5a2d93.b33b62",
      "type":"change",
      "z":"f2ce3087.ee968",
      "name":"tone_categories",
      "rules":[
         {
            "t":"set",
            "p":"payload",
            "pt":"msg",
            "to":"response.document_tone.tone_categories",
            "tot":"msg"
         }
      ],
      "action":"",
      "property":"",
      "from":"",
      "to":"",
      "reg":false,
      "x":660,
      "y":320,
      "wires":[
         [
            "dffc23d5.a9663"
         ]
      ]
   },
   {
      "id":"1f4d73c0.0f3c14",
      "type":"switch",
      "z":"f2ce3087.ee968",
      "name":"Select Emotion",
      "property":"topic",
      "propertyType":"msg",
      "rules":[
         {
            "t":"eq",
            "v":"Joy",
            "vt":"str"
         },
         {
            "t":"eq",
            "v":"Fear",
            "vt":"str"
         },
         {
            "t":"eq",
            "v":"Sadness",
            "vt":"str"
         },
         {
            "t":"eq",
            "v":"Anger",
            "vt":"str"
         },
         {
            "t":"eq",
            "v":"Disgust",
            "vt":"str"
         }
      ],
      "checkall":"true",
      "repair":false,
      "outputs":5,
      "x":180,
      "y":460,
      "wires":[
         [
            "8b9bb215.7ed26"
         ],
         [
            "3513595e.e6cf3e"
         ],
         [
            "b9003d45.14ee"
         ],
         [
            "6066fca0.647f8c"
         ],
         [
            "554595a.813296c"
         ]
      ]
   },
   {
      "id":"3513595e.e6cf3e",
      "type":"change",
      "z":"f2ce3087.ee968",
      "name":"Fear",
      "rules":[
         {
            "t":"set",
            "p":"payload",
            "pt":"msg",
            "to":"0,255,0",
            "tot":"str"
         }
      ],
      "action":"",
      "property":"",
      "from":"",
      "to":"",
      "reg":false,
      "x":350,
      "y":460,
      "wires":[
         [
            "6328f1ea.22058"
         ]
      ]
   },
   {
      "id":"6066fca0.647f8c",
      "type":"change",
      "z":"f2ce3087.ee968",
      "name":"Anger",
      "rules":[
         {
            "t":"set",
            "p":"payload",
            "pt":"msg",
            "to":"255,0,0",
            "tot":"str"
         }
      ],
      "action":"",
      "property":"",
      "from":"",
      "to":"",
      "reg":false,
      "x":390,
      "y":540,
      "wires":[
         [
            "6328f1ea.22058"
         ]
      ]
   },
   {
      "id":"b9003d45.14ee",
      "type":"change",
      "z":"f2ce3087.ee968",
      "name":"Sadness",
      "rules":[
         {
            "t":"set",
            "p":"payload",
            "pt":"msg",
            "to":"0,0,255",
            "tot":"str"
         }
      ],
      "action":"",
      "property":"",
      "from":"",
      "to":"",
      "reg":false,
      "x":400,
      "y":500,
      "wires":[
         [
            "6328f1ea.22058"
         ]
      ]
   },
   {
      "id":"8b9bb215.7ed26",
      "type":"change",
      "z":"f2ce3087.ee968",
      "name":"Joy",
      "rules":[
         {
            "t":"set",
            "p":"payload",
            "pt":"msg",
            "to":"255,255,0",
            "tot":"str"
         }
      ],
      "action":"",
      "property":"",
      "from":"",
      "to":"",
      "reg":false,
      "x":350,
      "y":420,
      "wires":[
         [
            "6328f1ea.22058"
         ]
      ]
   },
   {
      "id":"554595a.813296c",
      "type":"change",
      "z":"f2ce3087.ee968",
      "name":"Disgust",
      "rules":[
         {
            "t":"set",
            "p":"payload",
            "pt":"msg",
            "to":"221,160,221",
            "tot":"str"
         }
      ],
      "action":"",
      "property":"",
      "from":"",
      "to":"",
      "reg":false,
      "x":360,
      "y":580,
      "wires":[
         [
            "6328f1ea.22058"
         ]
      ]
   },
   {
      "id":"6328f1ea.22058",
      "type":"template",
      "z":"f2ce3087.ee968",
      "name":"Score tweet",
      "field":"payload",
      "fieldType":"msg",
      "format":"handlebars",
      "syntax":"mustache",
      "template":"This tweet expresses {{topic}} - {{tweet.text}}",
      "output":"str",
      "x":530,
      "y":440,
      "wires":[
         [
            "ea37a6d8.dd75d",
            "a60e5015.580b68"
         ]
      ]
   },
   {
      "id":"ea37a6d8.dd75d",
      "type":"debug",
      "z":"f2ce3087.ee968",
      "name":"",
      "active":true,
      "console":"false",
      "complete":"false",
      "x":590,
      "y":500,
      "wires":[

      ]
   },
   {
      "id":"a60e5015.580b68",
      "type":"watson-translator",
      "z":"f2ce3087.ee968",
      "name":"",
      "action":"translate",
      "basemodel":"en-tr",
      "domain":"general",
      "srclang":"en",
      "destlang":"es",
      "password":"pmistry@us.ibm.com",
      "apikey":"PF2WfTPM5NuU0ab5DcMJa7t6wqRP3UXu2hlhoFOnFryv",
      "custom":"",
      "domainhidden":"general",
      "srclanghidden":"en",
      "destlanghidden":"es",
      "basemodelhidden":"en-tr",
      "customhidden":"",
      "filetype":"forcedglossary",
      "trainid":"",
      "lgparams2":true,
      "neural":false,
      "default-endpoint":false,
      "service-endpoint":"",
      "x":630,
      "y":380,
      "wires":[
         [
            "e439f7a5.967798",
            "e87cc8f9.0d3b1"
         ]
      ]
   },
   {
      "id":"e439f7a5.967798",
      "type":"debug",
      "z":"f2ce3087.ee968",
      "name":"",
      "active":true,
      "tosidebar":true,
      "console":false,
      "tostatus":false,
      "complete":"payload",
      "targetType":"msg",
      "x":750,
      "y":460,
      "wires":[

      ]
   },
   {
      "id":"2b50d466.c015dc",
      "type":"change",
      "z":"f2ce3087.ee968",
      "name":"",
      "rules":[
         {
            "t":"set",
            "p":"payload",
            "pt":"msg",
            "to":"speech",
            "tot":"msg"
         }
      ],
      "action":"",
      "property":"",
      "from":"",
      "to":"",
      "reg":false,
      "x":1020,
      "y":380,
      "wires":[
         [
            "66c156b2.7d6878"
         ]
      ]
   },
   {
      "id":"66c156b2.7d6878",
      "type":"play audio",
      "z":"f2ce3087.ee968",
      "name":"",
      "voice":"",
      "x":1190,
      "y":380,
      "wires":[

      ]
   },
   {
      "id":"ca3a3fc7.8605d8",
      "type":"twitter in",
      "z":"f2ce3087.ee968",
      "twitter":"",
      "tags":"",
      "user":"false",
      "name":"Listen to twitter feed",
      "inputs":1,
      "x":190,
      "y":60,
      "wires":[
         [
            "edec68ad.93c13",
            "3cef19cd.214e16",
            "19037133.924c87"
         ]
      ]
   },
   {
      "id":"edec68ad.93c13",
      "type":"debug",
      "z":"f2ce3087.ee968",
      "name":"msg.tweet details",
      "active":true,
      "console":"false",
      "complete":"tweet",
      "x":570,
      "y":20,
      "wires":[

      ]
   },
   {
      "id":"3cef19cd.214e16",
      "type":"debug",
      "z":"f2ce3087.ee968",
      "name":"",
      "active":true,
      "console":"false",
      "complete":"tweet.text",
      "x":560,
      "y":60,
      "wires":[

      ]
   },
   {
      "id":"77693eef.07ad08",
      "type":"comment",
      "z":"f2ce3087.ee968",
      "name":"Pick a #hashtag to follow",
      "info":"",
      "x":200,
      "y":20,
      "wires":[

      ]
   }
]
```

####


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://nodered-dashboards.gitbook.io/node-red-dashboards/workshop/tweet-dashboard-example.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
