├── ibmcoder ├── node_change.png ├── node_debug.png ├── node_inject.png ├── node_switch.png ├── editor-default.png └── node_function.png ├── Screenshots ├── ToneAnalyzer.png ├── WeatherForecastinGerman.png ├── HelloWorld-Inject-annotated.png └── IchbineinBerliner-Translate-annotated.png ├── README.md ├── LICENSE └── NodeRED-Intro-examples.flow /ibmcoder/node_change.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/johnwalicki/Node-RED-Introduction101/master/ibmcoder/node_change.png -------------------------------------------------------------------------------- /ibmcoder/node_debug.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/johnwalicki/Node-RED-Introduction101/master/ibmcoder/node_debug.png -------------------------------------------------------------------------------- /ibmcoder/node_inject.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/johnwalicki/Node-RED-Introduction101/master/ibmcoder/node_inject.png -------------------------------------------------------------------------------- /ibmcoder/node_switch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/johnwalicki/Node-RED-Introduction101/master/ibmcoder/node_switch.png -------------------------------------------------------------------------------- /ibmcoder/editor-default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/johnwalicki/Node-RED-Introduction101/master/ibmcoder/editor-default.png -------------------------------------------------------------------------------- /ibmcoder/node_function.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/johnwalicki/Node-RED-Introduction101/master/ibmcoder/node_function.png -------------------------------------------------------------------------------- /Screenshots/ToneAnalyzer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/johnwalicki/Node-RED-Introduction101/master/Screenshots/ToneAnalyzer.png -------------------------------------------------------------------------------- /Screenshots/WeatherForecastinGerman.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/johnwalicki/Node-RED-Introduction101/master/Screenshots/WeatherForecastinGerman.png -------------------------------------------------------------------------------- /Screenshots/HelloWorld-Inject-annotated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/johnwalicki/Node-RED-Introduction101/master/Screenshots/HelloWorld-Inject-annotated.png -------------------------------------------------------------------------------- /Screenshots/IchbineinBerliner-Translate-annotated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/johnwalicki/Node-RED-Introduction101/master/Screenshots/IchbineinBerliner-Translate-annotated.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | This Node-RED Introduction 101 repository is useful as a pre-hackathon webinar introduction to Bluemix, Watson Cognitive Services and Node-RED. Many of the projects at your hackathon could use Node-Red on the IBM BlueMix platform to integrate devices, APIs and online services. It is essential that all participants have foundational knowledge of this technology prior to attending the event. 2 | 3 | Webinar Topics: 4 | 1. Creating a Bluemix Account 5 | 2. Bluemix Overview 6 | 3. Watson Cognitive Services Overview 7 | 4. Node-Red Overview 8 | - Concept of flows and nodes 9 | - Input & Outputs 10 | - Debug and inject nodes 11 | 5. Check out additional Node-RED flows in my [TJBot-Node-RED](https://github.com/johnwalicki/TJBot-Node-RED) repository. 12 | 13 | This Node-RED-Introduction101 repository includes a presentation, [Node-RED Flows](NodeRED-Intro-examples.flow), Node-RED Flow [screenshots](/Screenshots/) that can be used during a pre-hackathon webinar. 14 | 15 | Presenter: [John Walicki](https://github.com/johnwalicki/) 16 | 17 | ## Node-RED flows in this repository: 18 | This flow describes how to create the basic Hello World in a few steps. 19 | 1. Drag an Inject node from the palette 20 | 2. Drag a Debug node from the palette and wire the two nodes together 21 | 3. Double click on the Inject node and change it to inject an A-Z String "Hello World" 22 | 4. Press the Red Deploy button in the top Right corner. Press the blue Inject. The Hello World string will appear in the Debug area. 23 | ![Hello World](/Screenshots/HelloWorld-Inject-annotated.png?raw=true "Hello World") 24 | This flow describes how to use the language translation node: 25 | 5. Drag a Language Translation node from the palette. 26 | 6. Double click on the Language Translation node and select German 27 | 7. Press the Red Deploy button in the top Right corner. Press the blue Inject. The I am a Berliner string will appear in the Debug area. 28 | ![Language Translation](/Screenshots/IchbineinBerliner-Translate-annotated.png?raw=true "Ich bin ein Berliner") 29 | This flow speaks the Berlin weather forecast in German 30 | * Call the Weather Insights for the forecast in Berlin. 31 | * Builds a sentence 32 | * Call language translation to convert to German 33 | * Call Text to Speech to generate a WAV file 34 | * Plays the weather forecast in a German voice 35 | ![Weather Forecast](/Screenshots/WeatherForecastinGerman.png?raw=true "Speak the Berlin weather forecast in German") 36 | This flow analyzes incoming Tweets 37 | * Configure the Twitter node for a hashtag 38 | * Convert Tweets to speech and speak them 39 | * Call Tone Analysis node 40 | * Find the highest tone score 41 | * TXT Joyful tweets to a phone number 42 | ![Tone Analyzer](/Screenshots/ToneAnalyzer.png?raw=true "Twitter Analyzer flow") 43 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /NodeRED-Intro-examples.flow: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": "5bba8d86.6c7bbc", 4 | "type": "tab", 5 | "label": "Hello World" 6 | }, 7 | { 8 | "id": "2428501e.86545", 9 | "type": "tab", 10 | "label": "Hello World in German" 11 | }, 12 | { 13 | "id": "3e0df11a.8f1486", 14 | "type": "tab", 15 | "label": "Weather" 16 | }, 17 | { 18 | "id": "68157612.5bc228", 19 | "type": "tab", 20 | "label": "Tone Analzyer" 21 | }, 22 | { 23 | "id": "259cd171.16da96", 24 | "type": "twilio-api", 25 | "z": "", 26 | "sid": "", 27 | "from": "", 28 | "name": "" 29 | }, 30 | { 31 | "id": "a5421f62.7dc89", 32 | "type": "twitter-credentials", 33 | "z": "", 34 | "screen_name": "" 35 | }, 36 | 37 | { 38 | "id": "b1bcfaa8.6c3b28", 39 | "type": "comment", 40 | "z": "3e0df11a.8f1486", 41 | "name": "Berlin latitude/longitude - 52.50190,13.40868", 42 | "info": "", 43 | "x": 370, 44 | "y": 60, 45 | "wires": [] 46 | }, 47 | { 48 | "id": "d6cfd104.cef7c8", 49 | "type": "inject", 50 | "z": "5bba8d86.6c7bbc", 51 | "name": "", 52 | "topic": "", 53 | "payload": "Hello World", 54 | "payloadType": "str", 55 | "repeat": "", 56 | "crontab": "", 57 | "once": false, 58 | "x": 230, 59 | "y": 120, 60 | "wires": [ 61 | [ 62 | "11e5f89a.e94297" 63 | ] 64 | ] 65 | }, 66 | { 67 | "id": "11e5f89a.e94297", 68 | "type": "debug", 69 | "z": "5bba8d86.6c7bbc", 70 | "name": "", 71 | "active": true, 72 | "console": "false", 73 | "complete": "false", 74 | "x": 470, 75 | "y": 120, 76 | "wires": [] 77 | }, 78 | { 79 | "id": "7f5ab901.5f032", 80 | "type": "inject", 81 | "z": "2428501e.86545", 82 | "name": "", 83 | "topic": "", 84 | "payload": "I am a Berliner", 85 | "payloadType": "str", 86 | "repeat": "", 87 | "crontab": "", 88 | "once": false, 89 | "x": 180, 90 | "y": 100, 91 | "wires": [ 92 | [ 93 | "94964a2e.253ce8" 94 | ] 95 | ] 96 | }, 97 | { 98 | "id": "84f138eb.2f085", 99 | "type": "debug", 100 | "z": "2428501e.86545", 101 | "name": "", 102 | "active": true, 103 | "console": "false", 104 | "complete": "false", 105 | "x": 610, 106 | "y": 100, 107 | "wires": [] 108 | }, 109 | { 110 | "id": "94964a2e.253ce8", 111 | "type": "watson-translator", 112 | "z": "2428501e.86545", 113 | "name": "", 114 | "action": "translate", 115 | "basemodel": "ar-en", 116 | "domain": "news", 117 | "srclang": "en", 118 | "destlang": "de", 119 | "password": "", 120 | "custom": "", 121 | "domainhidden": "news", 122 | "srclanghidden": "en", 123 | "destlanghidden": "de", 124 | "basemodelhidden": "ar-en", 125 | "customhidden": "", 126 | "filetype": "forcedglossary", 127 | "trainid": "", 128 | "lgparams2": true, 129 | "ldparamshidden2": "true", 130 | "x": 400, 131 | "y": 100, 132 | "wires": [ 133 | [ 134 | "84f138eb.2f085" 135 | ] 136 | ] 137 | }, 138 | { 139 | "id": "1263e720.6beaf9", 140 | "type": "weather_insights", 141 | "z": "3e0df11a.8f1486", 142 | "name": "", 143 | "host": "twcservice.mybluemix.net", 144 | "service": "/forecast/daily/10day.json", 145 | "geocode": "52.50190,13.40868", 146 | "units": "m", 147 | "language": "", 148 | "x": 360, 149 | "y": 100, 150 | "wires": [ 151 | [ 152 | "cd0d81fa.515f6", 153 | "16065012.0f1388" 154 | ] 155 | ] 156 | }, 157 | { 158 | "id": "a15919d7.a11ef8", 159 | "type": "inject", 160 | "z": "3e0df11a.8f1486", 161 | "name": "Start Forecast Report", 162 | "topic": "", 163 | "payload": "true", 164 | "payloadType": "bool", 165 | "repeat": "", 166 | "crontab": "", 167 | "once": false, 168 | "x": 140, 169 | "y": 100, 170 | "wires": [ 171 | [ 172 | "1263e720.6beaf9" 173 | ] 174 | ] 175 | }, 176 | { 177 | "id": "cd0d81fa.515f6", 178 | "type": "debug", 179 | "z": "3e0df11a.8f1486", 180 | "name": "", 181 | "active": true, 182 | "console": "false", 183 | "complete": "forecasts", 184 | "x": 580, 185 | "y": 100, 186 | "wires": [] 187 | }, 188 | { 189 | "id": "16065012.0f1388", 190 | "type": "function", 191 | "z": "3e0df11a.8f1486", 192 | "name": "Find forecast for Friday - start of the Hackathon", 193 | "func": "// The Hackathon starts on a few days from now\n// WeatherInsights returned the 10 day forecast.\n// Friday is a few days from now so let's loop through and look for .dow == Friday\nvar i = 0;\nwhile( msg.forecasts[i].dow != \"Friday\") {\n i++;\n}\nvar BerlinForecast = \"The forecast for \" + msg.forecasts[i].dow +\" is \"+ msg.forecasts[i].narrative;\nmsg.payload = BerlinForecast;\nreturn msg;", 194 | "outputs": 1, 195 | "noerr": 0, 196 | "x": 240, 197 | "y": 200, 198 | "wires": [ 199 | [ 200 | "6700f1c3.04f2", 201 | "66803a13.fc76cc" 202 | ] 203 | ] 204 | }, 205 | { 206 | "id": "6700f1c3.04f2", 207 | "type": "debug", 208 | "z": "3e0df11a.8f1486", 209 | "name": "", 210 | "active": true, 211 | "console": "false", 212 | "complete": "false", 213 | "x": 570, 214 | "y": 200, 215 | "wires": [] 216 | }, 217 | { 218 | "id": "6ea21736.8706e8", 219 | "type": "watson-text-to-speech", 220 | "z": "3e0df11a.8f1486", 221 | "name": "", 222 | "lang": "de-DE", 223 | "langhidden": "de-DE", 224 | "langcustom": "NoCustomisationSetting", 225 | "langcustomhidden": "", 226 | "voice": "de-DE_BirgitVoice", 227 | "voicehidden": "en-US_MichaelVoice", 228 | "format": "audio/wav", 229 | "password": "", 230 | "x": 340, 231 | "y": 300, 232 | "wires": [ 233 | [ 234 | "2546a272.4f258e" 235 | ] 236 | ] 237 | }, 238 | { 239 | "id": "2546a272.4f258e", 240 | "type": "change", 241 | "z": "3e0df11a.8f1486", 242 | "name": "", 243 | "rules": [ 244 | { 245 | "t": "set", 246 | "p": "payload", 247 | "pt": "msg", 248 | "to": "speech", 249 | "tot": "msg" 250 | } 251 | ], 252 | "action": "", 253 | "property": "", 254 | "from": "", 255 | "to": "", 256 | "reg": false, 257 | "x": 520, 258 | "y": 300, 259 | "wires": [ 260 | [ 261 | "857cce75.8a79b8" 262 | ] 263 | ] 264 | }, 265 | { 266 | "id": "857cce75.8a79b8", 267 | "type": "play audio", 268 | "z": "3e0df11a.8f1486", 269 | "name": "", 270 | "voice": "", 271 | "x": 690, 272 | "y": 300, 273 | "wires": [] 274 | }, 275 | { 276 | "id": "66803a13.fc76cc", 277 | "type": "watson-translator", 278 | "z": "3e0df11a.8f1486", 279 | "name": "", 280 | "action": "translate", 281 | "basemodel": "", 282 | "domain": "news", 283 | "srclang": "en", 284 | "destlang": "fr", 285 | "password": "", 286 | "custom": "", 287 | "domainhidden": "", 288 | "srclanghidden": "", 289 | "destlanghidden": "", 290 | "basemodelhidden": "", 291 | "customhidden": "", 292 | "filetype": "forcedglossary", 293 | "trainid": "", 294 | "lgparams2": "lparams", 295 | "ldparamshidden2": "", 296 | "x": 150, 297 | "y": 300, 298 | "wires": [ 299 | [ 300 | "6ea21736.8706e8" 301 | ] 302 | ] 303 | }, 304 | { 305 | "id": "e20ea1d8.3871e8", 306 | "type": "debug", 307 | "z": "68157612.5bc228", 308 | "name": "Tone categories", 309 | "active": true, 310 | "console": "false", 311 | "complete": "payload", 312 | "x": 940, 313 | "y": 380, 314 | "wires": [] 315 | }, 316 | { 317 | "id": "8fe460ad.9377f", 318 | "type": "function", 319 | "z": "68157612.5bc228", 320 | "name": "HighScore", 321 | "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 \n//rename tone_id to topic\nvar myscore = 0; \nvar mynewmsg ={};\n//msg.payload = emotions;\nfor (var i=0; i myscore)\n {\n msg.payload = emotions[i].score;\n msg.topic = emotions[i].tone_name;\n myscore = emotions[i].score;\n }\n // node.send(msg);\n}\nmynewmsg = msg;\nreturn mynewmsg;", 322 | "outputs": 1, 323 | "noerr": 0, 324 | "x": 710, 325 | "y": 420, 326 | "wires": [ 327 | [ 328 | "22b1c88f.238988", 329 | "b1888a9a.8e6c38" 330 | ] 331 | ] 332 | }, 333 | { 334 | "id": "22b1c88f.238988", 335 | "type": "debug", 336 | "z": "68157612.5bc228", 337 | "name": "Score", 338 | "active": true, 339 | "console": "false", 340 | "complete": "topic", 341 | "x": 910, 342 | "y": 420, 343 | "wires": [] 344 | }, 345 | { 346 | "id": "7c7a7a36.fc348c", 347 | "type": "inject", 348 | "z": "68157612.5bc228", 349 | "name": "Angry test", 350 | "topic": "", 351 | "payload": "I hate boring demos", 352 | "payloadType": "str", 353 | "repeat": "", 354 | "crontab": "", 355 | "once": false, 356 | "x": 120, 357 | "y": 280, 358 | "wires": [ 359 | [ 360 | "607656d4.7393b8" 361 | ] 362 | ] 363 | }, 364 | { 365 | "id": "9ece7bbd.6011f8", 366 | "type": "debug", 367 | "z": "68157612.5bc228", 368 | "name": "Print msg.response", 369 | "active": false, 370 | "console": "false", 371 | "complete": "response", 372 | "x": 730, 373 | "y": 340, 374 | "wires": [] 375 | }, 376 | { 377 | "id": "449eac7f.9a7a2c", 378 | "type": "watson-tone-analyzer-v3", 379 | "z": "68157612.5bc228", 380 | "name": "Analyze Tone", 381 | "tones": "emotion", 382 | "sentences": "true", 383 | "contentType": "false", 384 | "x": 500, 385 | "y": 380, 386 | "wires": [ 387 | [ 388 | "8fe460ad.9377f", 389 | "9ece7bbd.6011f8", 390 | "875a664c.07aa7" 391 | ] 392 | ] 393 | }, 394 | { 395 | "id": "875a664c.07aa7", 396 | "type": "change", 397 | "z": "68157612.5bc228", 398 | "name": "tone_categories", 399 | "rules": [ 400 | { 401 | "t": "set", 402 | "p": "payload", 403 | "pt": "msg", 404 | "to": "response.document_tone.tone_categories", 405 | "tot": "msg" 406 | } 407 | ], 408 | "action": "", 409 | "property": "", 410 | "from": "", 411 | "to": "", 412 | "reg": false, 413 | "x": 720, 414 | "y": 380, 415 | "wires": [ 416 | [ 417 | "e20ea1d8.3871e8" 418 | ] 419 | ] 420 | }, 421 | { 422 | "id": "fb3cd3.a661933", 423 | "type": "twitter in", 424 | "z": "68157612.5bc228", 425 | "twitter": "a5421f62.7dc89", 426 | "tags": "", 427 | "user": "false", 428 | "name": "", 429 | "topic": "tweets", 430 | "inputs": 1, 431 | "x": 130, 432 | "y": 80, 433 | "wires": [ 434 | [ 435 | "4fe56b96.076f74", 436 | "59a78fef.a8d2b8", 437 | "607656d4.7393b8" 438 | ] 439 | ] 440 | }, 441 | { 442 | "id": "4fe56b96.076f74", 443 | "type": "debug", 444 | "z": "68157612.5bc228", 445 | "name": "", 446 | "active": false, 447 | "console": "false", 448 | "complete": "tweet.text", 449 | "x": 320, 450 | "y": 120, 451 | "wires": [] 452 | }, 453 | { 454 | "id": "e5853bba.da1d98", 455 | "type": "inject", 456 | "z": "68157612.5bc228", 457 | "name": "Happy test", 458 | "topic": "", 459 | "payload": "every one is awesome", 460 | "payloadType": "str", 461 | "repeat": "", 462 | "crontab": "", 463 | "once": false, 464 | "x": 120, 465 | "y": 200, 466 | "wires": [ 467 | [ 468 | "607656d4.7393b8" 469 | ] 470 | ] 471 | }, 472 | { 473 | "id": "607656d4.7393b8", 474 | "type": "change", 475 | "z": "68157612.5bc228", 476 | "name": "", 477 | "rules": [ 478 | { 479 | "t": "set", 480 | "p": "payload", 481 | "pt": "msg", 482 | "to": "tweet.text", 483 | "tot": "msg" 484 | } 485 | ], 486 | "action": "", 487 | "property": "", 488 | "from": "", 489 | "to": "", 490 | "reg": false, 491 | "x": 320, 492 | "y": 200, 493 | "wires": [ 494 | [ 495 | "449eac7f.9a7a2c", 496 | "8f021b.402495e8", 497 | "c04ebbc9.e8ff48" 498 | ] 499 | ] 500 | }, 501 | { 502 | "id": "5e6db815.0feda8", 503 | "type": "inject", 504 | "z": "68157612.5bc228", 505 | "name": "Sadness test", 506 | "topic": "", 507 | "payload": "This is miserable and sad", 508 | "payloadType": "str", 509 | "repeat": "", 510 | "crontab": "", 511 | "once": false, 512 | "x": 110, 513 | "y": 240, 514 | "wires": [ 515 | [ 516 | "607656d4.7393b8" 517 | ] 518 | ] 519 | }, 520 | { 521 | "id": "59a78fef.a8d2b8", 522 | "type": "debug", 523 | "z": "68157612.5bc228", 524 | "name": "", 525 | "active": true, 526 | "console": "false", 527 | "complete": "payload", 528 | "x": 310, 529 | "y": 80, 530 | "wires": [] 531 | }, 532 | { 533 | "id": "8f021b.402495e8", 534 | "type": "debug", 535 | "z": "68157612.5bc228", 536 | "name": "", 537 | "active": true, 538 | "console": "false", 539 | "complete": "false", 540 | "x": 510, 541 | "y": 160, 542 | "wires": [] 543 | }, 544 | { 545 | "id": "b1888a9a.8e6c38", 546 | "type": "switch", 547 | "z": "68157612.5bc228", 548 | "name": "Select Emotion", 549 | "property": "topic", 550 | "propertyType": "msg", 551 | "rules": [ 552 | { 553 | "t": "eq", 554 | "v": "Joy", 555 | "vt": "str" 556 | }, 557 | { 558 | "t": "eq", 559 | "v": "Fear", 560 | "vt": "str" 561 | }, 562 | { 563 | "t": "eq", 564 | "v": "Sadness", 565 | "vt": "str" 566 | }, 567 | { 568 | "t": "eq", 569 | "v": "Anger", 570 | "vt": "str" 571 | }, 572 | { 573 | "t": "eq", 574 | "v": "Disgust", 575 | "vt": "str" 576 | }, 577 | { 578 | "t": "else" 579 | } 580 | ], 581 | "checkall": "true", 582 | "outputs": 6, 583 | "x": 500, 584 | "y": 600, 585 | "wires": [ 586 | [ 587 | "14702aa1.b7b9a5" 588 | ], 589 | [], 590 | [], 591 | [], 592 | [], 593 | [] 594 | ] 595 | }, 596 | { 597 | "id": "c04ebbc9.e8ff48", 598 | "type": "watson-text-to-speech", 599 | "z": "68157612.5bc228", 600 | "name": "", 601 | "lang": "en-US", 602 | "langhidden": "en-US", 603 | "langcustom": "NoCustomisationSetting", 604 | "langcustomhidden": "", 605 | "voice": "en-US_MichaelVoice", 606 | "voicehidden": "en-US_MichaelVoice", 607 | "format": "audio/wav", 608 | "password": "5824BY7NvNkT", 609 | "x": 520, 610 | "y": 200, 611 | "wires": [ 612 | [ 613 | "1d95ddc8.59d4ca" 614 | ] 615 | ] 616 | }, 617 | { 618 | "id": "42e4227b.f67dbc", 619 | "type": "play audio", 620 | "z": "68157612.5bc228", 621 | "name": "", 622 | "voice": "", 623 | "x": 910, 624 | "y": 200, 625 | "wires": [] 626 | }, 627 | { 628 | "id": "1d95ddc8.59d4ca", 629 | "type": "function", 630 | "z": "68157612.5bc228", 631 | "name": "Speech Buffer", 632 | "func": "msg.payload = msg.speech;\nreturn msg;", 633 | "outputs": 1, 634 | "noerr": 0, 635 | "x": 720, 636 | "y": 200, 637 | "wires": [ 638 | [ 639 | "42e4227b.f67dbc" 640 | ] 641 | ] 642 | }, 643 | { 644 | "id": "1bdeaf5b.2e8921", 645 | "type": "twilio out", 646 | "z": "68157612.5bc228", 647 | "service": "_ext_", 648 | "twilio": "259cd171.16da96", 649 | "from": "", 650 | "number": "15515551234", 651 | "name": "", 652 | "x": 880, 653 | "y": 560, 654 | "wires": [] 655 | }, 656 | { 657 | "id": "14702aa1.b7b9a5", 658 | "type": "function", 659 | "z": "68157612.5bc228", 660 | "name": "Joy", 661 | "func": "// TXT a Joyful message to my Mobile phone\nmsg.payload = msg.topic;\n\n// Do something useful here.\nreturn msg;", 662 | "outputs": 1, 663 | "noerr": 0, 664 | "x": 690, 665 | "y": 560, 666 | "wires": [ 667 | [ 668 | "1bdeaf5b.2e8921" 669 | ] 670 | ] 671 | } 672 | ] 673 | --------------------------------------------------------------------------------