Bluemix-GameStopHackathon #16

Our project fetch twitter data and use IBM BigInsights hadoop to analyze sentiment, evaluate the score to select game in GameStop API database to get the game promotion, then recommend to potential customer, show BigSheets and push notification on Android mobile phone.

[{"id":"f0148814.0feb78","type":"mongodb","z":"d6b0da3a.294f28","hostname":"ds047524.mongolab.com","port":"47524","db":"tweetsentiments","name":"tweets"},{"id":"67d55f92.982aa","type":"twitter in","z":"d6b0da3a.294f28","twitter":"","tags":"GameStop,IBM,Borderlands: The Handsome Collection,Fallout 4,Fallout 4 Pip-Boy Edition","user":"false","name":"Games Info on tweet","topic":"tweets","x":260.3571319580078,"y":326.32143211364746,"wires":[["e0a4611f.1f5ba","5d0190c8.a2fe7","dd1c1faf.22e3e","537574d9.ac8a8c"]]},{"id":"e0a4611f.1f5ba","type":"debug","z":"d6b0da3a.294f28","name":"","active":false,"console":"false","complete":"payload","x":564.0000305175781,"y":415.35716819763184,"wires":[]},{"id":"5d0190c8.a2fe7","type":"sentiment","z":"d6b0da3a.294f28","name":"","x":482.7143020629883,"y":327.8571472167969,"wires":[["7388498d.8c77b8"]]},{"id":"7388498d.8c77b8","type":"function","z":"d6b0da3a.294f28","name":"sentiment analysis","func":"var d = new Date();\nvar utc = d.getTime() - (d.getTimezoneOffset() * 60000);\nvar nd = new Date(utc + (3600000*+8));\nvar year = nd.getFullYear();\nvar month = nd.getMonth()+1; // 1-Jan, 2-Feb, etc.\nvar day = nd.getDate();\nvar hour = nd.getHours();\nvar minute = nd.getMinutes();\nvar second = nd.getSeconds();\nvar game = ['GameStop','IBM', 'Borderlands: The Handsome Collection', 'Fallout 4','Fallout 4 Pip-Boy Edition'];\nfor (var i = 0; i < game.length; i++) {\n    if (msg.payload.indexOf(game[i]) != -1) {\n        tt = game[i];\n        break;\n    }\n}\nvar newMsg =\n{\n payload:\n {\n tweet: tt,\n score: msg.sentiment.score,\n }\n};\nreturn newMsg; ","outputs":1,"noerr":0,"x":673.4285583496094,"y":223.71430206298828,"wires":[["ee06cc81.11f93","af23bcf7.50dc4","249a71a4.db658e"]]},{"id":"ee06cc81.11f93","type":"debug","z":"d6b0da3a.294f28","name":"","active":false,"console":"false","complete":"payload","x":943.6507797241211,"y":195.74603271484375,"wires":[]},{"id":"dd1c1faf.22e3e","type":"mongodb out","z":"d6b0da3a.294f28","service":"_ext_","mongodb":"f0148814.0feb78","name":"","collection":"sentiment","payonly":true,"upsert":false,"multi":false,"operation":"store","x":569.8571701049805,"y":458.71430492401123,"wires":[]},{"id":"af23bcf7.50dc4","type":"mongodb out","z":"d6b0da3a.294f28","service":"_ext_","mongodb":"f0148814.0feb78","name":"","collection":"sentiment","payonly":true,"upsert":false,"multi":false,"operation":"store","x":957.0793533325195,"y":154.39684104919434,"wires":[]},{"id":"fde832e.f0217d","type":"http in","z":"d6b0da3a.294f28","name":"view_sentiments","url":"/view_sentiments","method":"get","swaggerDoc":"","x":238.85712432861328,"y":559.7142944335938,"wires":[["b5931876.4a6ce8"]]},{"id":"b5931876.4a6ce8","type":"mongodb in","z":"d6b0da3a.294f28","service":"_ext_","mongodb":"f0148814.0feb78","name":"","collection":"sentiment","operation":"find","x":442.4286003112793,"y":560.7143115997314,"wires":[["100c5dd1.eff3a2"]]},{"id":"3b87b266.c4784e","type":"http response","z":"d6b0da3a.294f28","name":"view_sentiments","x":912.1428260803223,"y":561.8571510314941,"wires":[]},{"id":"100c5dd1.eff3a2","type":"json","z":"d6b0da3a.294f28","name":"get sentiments result","x":679.142822265625,"y":561.2857570648193,"wires":[["3b87b266.c4784e"]]},{"id":"537574d9.ac8a8c","type":"ibm hdfs","z":"d6b0da3a.294f28","name":"analysis on hadoop","filename":"/tweets/analysis","appendNewline":true,"overwriteFile":false,"x":552.6984786987305,"y":103.09524822235107,"wires":[]},{"id":"249a71a4.db658e","type":"function","z":"d6b0da3a.294f28","name":"Switch based on Sentiment.Score","func":"if (msg.payload.score > 2) {\n    name = msg.payload.tweet + ', Strongly recommendation!';\n} else if (msg.payload.score < -2) {\n    name = msg.payload.tweet + ', Need to analysis further...';\n} else {\n    name = msg.payload.tweet + ', Neutral';\n}\nreturn name;","outputs":1,"noerr":0,"x":955.7142639160156,"y":317.3016128540039,"wires":[["19143c87.e6ebc3"]]},{"id":"19143c87.e6ebc3","type":"debug","z":"d6b0da3a.294f28","name":"","active":true,"console":"false","complete":"true","x":1139.5237503051758,"y":329.68254566192627,"wires":[]},{"id":"92d3da36.6d2c28","type":"comment","z":"d6b0da3a.294f28","name":"BigInsights Analysis for Hadoop ","info":"Demo Text Analysis and BigSheets.","x":560.0001068115234,"y":54.28571128845215,"wires":[]},{"id":"e4c63d1a.1b39c","type":"comment","z":"d6b0da3a.294f28","name":"Recommendation base on Networking","info":"1. Most Popular Games shared on social media currently.\n2. Based on Customer's own networking.\n3. Calculate the sore based on weight of 1 & 2","x":224.28572845458984,"y":247.14285945892334,"wires":[]},{"id":"2ae8e2d4.d5171e","type":"inject","z":"d6b0da3a.294f28","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":154.2857208251953,"y":804.2857828140259,"wires":[["6ebcb02e.91435"]]},{"id":"3c1a72a.fc3e58e","type":"http request","z":"d6b0da3a.294f28","name":"GetAllConsoles","method":"GET","ret":"obj","url":"","x":488.2857208251953,"y":897.2857828140259,"wires":[["bbc80dd8.4437f","9487cd7a.6b783"]]},{"id":"6ebcb02e.91435","type":"function","z":"d6b0da3a.294f28","name":"Set Global Context","func":"context.global.sjsuapp = {};\ncontext.global.sjsuapp.secret = \"G0dG7xO4nL4fL1sV3lK6bF3iL8iN3bY4hD4tI3wE3hD3pS5cU2\";\ncontext.global.sjsuapp.clientID= \"e4fcb84f-4723-458b-8566-3841c00e2735\";\nreturn msg;","outputs":1,"noerr":0,"x":398.2857208251953,"y":803.2857828140259,"wires":[["fdd0812a.022f8"]]},{"id":"fdd0812a.022f8","type":"function","z":"d6b0da3a.294f28","name":"Set URL for getConsoles","func":"msg.url = \"https://api.apim.ibmcloud.com/gamestop/prod/gamestop/Products/Consoles?client_secret=\" +\n            context.global.sjsuapp.secret + \"&client_id=\" +\n            context.global.sjsuapp.clientID;\nreturn msg;","outputs":1,"noerr":0,"x":249.2857208251953,"y":896.2857828140259,"wires":[["3c1a72a.fc3e58e"]]},{"id":"dd6fd9c.f229028","type":"http in","z":"d6b0da3a.294f28","name":"EndPoint: getConsoles","url":"/getConsoles","method":"get","swaggerDoc":"","x":151.2857208251953,"y":713.2857580184937,"wires":[["6ebcb02e.91435"]]},{"id":"bbc80dd8.4437f","type":"debug","z":"d6b0da3a.294f28","name":"Debug: getConsole output","active":true,"console":"false","complete":"payload","x":631.2857208251953,"y":838.2857828140259,"wires":[]},{"id":"63bebca8.9c4144","type":"http response","z":"d6b0da3a.294f28","name":"Response: getConsole","x":764.2857208251953,"y":997.2857828140259,"wires":[]},{"id":"34de8b7.fcb2174","type":"template","z":"d6b0da3a.294f28","name":"Format HTML Response","field":"payload","format":"handlebars","template":"This the first console in the list:\n{{payload}}\n","x":520.2857208251953,"y":995.2857828140259,"wires":[["63bebca8.9c4144"]]},{"id":"9487cd7a.6b783","type":"function","z":"d6b0da3a.294f28","name":"Format Msg","func":"var txtMsg  = 324752;\nmsg.payload = {\n    \"msg\" : \"hello\",\n    \"id\" : txtMsg\n};\nreturn msg;","outputs":1,"noerr":0,"x":236.2857208251953,"y":998.2857828140259,"wires":[["34de8b7.fcb2174","bcea6a50.431598"]]},{"id":"bcea6a50.431598","type":"debug","z":"d6b0da3a.294f28","name":"Debug: Formatted Text","active":true,"console":"false","complete":"payload","x":365.2857208251953,"y":1082.2857828140259,"wires":[]},{"id":"51680eb9.ae97f","type":"comment","z":"d6b0da3a.294f28","name":"Notification on your phone","info":"","x":168.71429443359375,"y":665.7142486572266,"wires":[]}]

Flow Info

Created 9 years, 1 month ago
Rating: not yet rated

Owner

Actions

Rate:

Node Types

Core
  • comment (x3)
  • debug (x5)
  • function (x5)
  • http in (x2)
  • http request (x1)
  • http response (x2)
  • inject (x1)
  • json (x1)
  • template (x1)
Other
  • ibm hdfs (x1)
  • mongodb (x1)
  • mongodb in (x1)
  • mongodb out (x2)
  • sentiment (x1)
  • twitter in (x1)

Tags

  • Bluemix-GameStopHackathon
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option