Watson Personality Insights + Language Translator

The purpose of this flow is to perform personality analysis on a series of Portuguese posts.

It has 3 main flows

The first flow will perform:

  1. Read a RSS feed
  2. Perform HTTP request for each entry
  3. Translate from Portuguese to English
  4. Save to Cloudant

The second flow will just read everything from Cloudant and post it as an API

The third flow is an Angular 1 web page to show the data to the customer using bootstrap.

There is also an option to just present the data as an "ugly" html.

[{"id":"67fc8e52.7235c8","type":"cloudant out","z":"69c5ecdf.f1513c","name":"DB","cloudant":"","database":"posts","service":"eriknetonr-cloudantNoSQLDB","payonly":false,"operation":"insert","x":775.5,"y":134.5,"wires":[]},{"id":"534a87a5.55caf","type":"http in","z":"69c5ecdf.f1513c","name":"","url":"/show","method":"get","swaggerDoc":"","x":78.4999885559082,"y":541.9999933242798,"wires":[["b278f3cb.ec7cf"]]},{"id":"c383b467.f379b8","type":"cloudant in","z":"69c5ecdf.f1513c","name":"DB","cloudant":"","database":"posts","service":"eriknetonr-cloudantNoSQLDB","search":"_all_","design":"","index":"","x":456.99998474121094,"y":576,"wires":[["a657eca3.a4b5a8"]]},{"id":"989fd942.db45c8","type":"feedparse","z":"69c5ecdf.f1513c","name":"Feed","url":"http://feeds.feedburner.com/meiobit","interval":"0","x":55,"y":35,"wires":[["95d10c9a.00b798"]]},{"id":"cff8267f.61841","type":"watson-personality-insights-v3","z":"69c5ecdf.f1513c","name":"","inputlang":"en","outputlang":"en","rawscores":true,"consumption":true,"x":355,"y":143,"wires":[["ab2003e.2f2c98"]]},{"id":"b8779aec.7b16d8","type":"http response","z":"69c5ecdf.f1513c","name":"","x":771.5,"y":578.75,"wires":[]},{"id":"a657eca3.a4b5a8","type":"template","z":"69c5ecdf.f1513c","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"<title>Resultados do Watson</title>\n\n{{#payload}}\n    <h3>\n        <a href=\"{{url}}\">{{url}}</a>\n    </h3>\n    <ul>\n        {{#insights.personality}}\n            <li>\n                {{name}}\n                {{percentile}}\n            </li>\n        {{/insights.personality}}\n    </ul>\n{{/payload}}\n","x":622.5,"y":592.25,"wires":[["b8779aec.7b16d8"]]},{"id":"f34da600.b1a1","type":"watson-translator","z":"69c5ecdf.f1513c","name":"","action":"translate","basemodel":"ar-en","domain":"news","srclang":"pt","destlang":"en","password":"","custom":"","domainhidden":"news","srclanghidden":"pt","destlanghidden":"en","basemodelhidden":"","customhidden":"","filetype":"forcedglossary","trainid":"","lgparams2":true,"ldparamshidden2":"true","x":712,"y":38,"wires":[["7d08dc68.974184"]]},{"id":"8e702b8d.e1203","type":"http in","z":"69c5ecdf.f1513c","name":"","url":"/news","method":"get","swaggerDoc":"","x":78,"y":385,"wires":[["30547fba.e7e5e"]]},{"id":"85e2346a.ebe01","type":"http response","z":"69c5ecdf.f1513c","name":"","x":625,"y":429,"wires":[]},{"id":"30547fba.e7e5e","type":"template","z":"69c5ecdf.f1513c","name":"","field":"payload","fieldType":"msg","format":"html","syntax":"plain","template":"<!DOCTYPE html>\n<html>\n    <head>\n          <link rel=\"stylesheet\" href=\"https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css\">\n          <script src=\"https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js\"></script>\n          <script src=\"https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js\"></script>\n          <script src=\"https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js\"></script>\n    </head>\n\n<body>\n<div class=\"container\">\n    <title>Resultados com Bootstrap / AngularJs</title>\n    <h1>Resultados do Watson para feed de noticias</h1>\n    <div ng-app=\"myApp\" ng-controller=\"myCtrl\">\n        <div class = \"row\" ng-repeat=\"line in news\">\n            <div class = \"row\">\n                <h3><a href={{line.url}} target=\"_blank\">{{line.title}}</a></h3>\n                <div class=\"col-sm-4\">\n                    <div class = \"row\" ng-repeat=\"subline in line.insights.personality\">\n                        <div class=\"col-sm-6\">\n                            {{subline.name}}\n                        </div>                            \n                        <div class=\"col-sm-3 text-right\">\n                            {{(subline.percentile*100).toFixed(2)}}%\n                        </div>\n                    </div>\n                </div>\n                <div class=\"col-sm-4\">\n                    <div class = \"row\" ng-repeat=\"subline in line.insights.needs\">\n                        <div class=\"col-sm-6\">\n                            {{subline.name}}\n                        </div>                            \n                        <div class=\"col-sm-3 text-right\">\n                            {{(subline.percentile*100).toFixed(2)}}%\n                        </div>\n                    </div>\n                </div>\n                <div class=\"col-sm-4\">\n                    <div class = \"row\" ng-repeat=\"subline in line.insights.values\">\n                        <div class=\"col-sm-6\">\n                            {{subline.name}}\n                        </div>                            \n                        <div class=\"col-sm-3 text-right\">\n                            {{(subline.percentile*100).toFixed(2)}}%\n                        </div>\n                    </div>\n                </div>\n            </div>\n    \n        </div>\n    \n    </div>\n</div>\n<script>\nvar app = angular.module('myApp', []);\napp.controller('myCtrl', function($scope,$http) {\n    $scope.news = [];\n\n    $http({\n        method: 'GET',\n        url: '/results'\n       }).then(function successCallback(response) {\n            $scope.news = [];\n\n            for (x=0;x<response.data.length;x++) {\n                $scope.news.push(response.data[x]);\n            }\n       });\n    \n});\n\n</script>\n\n</body>\n</html>\n\n","x":312,"y":399,"wires":[["85e2346a.ebe01"]]},{"id":"1f8f39d4.bb4906","type":"http in","z":"69c5ecdf.f1513c","name":"","url":"/results","method":"get","swaggerDoc":"","x":86,"y":289,"wires":[["f8decddc.75c6"]]},{"id":"bc38a959.90d1f","type":"http response","z":"69c5ecdf.f1513c","name":"","x":561,"y":289,"wires":[]},{"id":"f8decddc.75c6","type":"cloudant in","z":"69c5ecdf.f1513c","name":"","cloudant":"","database":"posts","service":"eriknetonr-cloudantNoSQLDB","search":"_all_","design":"","index":"","x":348,"y":295,"wires":[["bc38a959.90d1f"]]},{"id":"ee6560d6.4d25e8","type":"http request","z":"69c5ecdf.f1513c","name":"","method":"GET","ret":"txt","url":"","tls":"","x":349,"y":39,"wires":[["153b1477.4488c4"]]},{"id":"95d10c9a.00b798","type":"function","z":"69c5ecdf.f1513c","name":"","func":"msg.url = msg.topic;\nreturn msg;","outputs":1,"noerr":0,"x":194,"y":41,"wires":[["ee6560d6.4d25e8"]]},{"id":"ab2003e.2f2c98","type":"function","z":"69c5ecdf.f1513c","name":"","func":"var newmsg = msg;\nnewmsg = {\n    _id: msg.url,\n    url: msg.url,\n    title: msg.article.title,\n    insights: msg.insights\n};\nmsg = newmsg;\n\nreturn msg;\n","outputs":1,"noerr":0,"x":514,"y":142,"wires":[["676a938.3f64aec"]]},{"id":"b278f3cb.ec7cf","type":"function","z":"69c5ecdf.f1513c","name":"","func":"msg.payload = {limit:1};\nreturn msg;","outputs":1,"noerr":0,"x":242,"y":558,"wires":[["c383b467.f379b8"]]},{"id":"153b1477.4488c4","type":"html","z":"69c5ecdf.f1513c","name":"","tag":"div.container","ret":"text","as":"single","x":516,"y":39,"wires":[["f34da600.b1a1"]]},{"id":"69653699.06399","type":"function","z":"69c5ecdf.f1513c","name":"","func":"msg.payload = JSON.stringify(msg.translation.response);\nreturn msg;","outputs":1,"noerr":0,"x":188.5,"y":140,"wires":[["cff8267f.61841"]]},{"id":"7d08dc68.974184","type":"switch","z":"69c5ecdf.f1513c","name":"","property":"translation.response.word_count","propertyType":"msg","rules":[{"t":"gte","v":"100","vt":"str"}],"checkall":"true","outputs":1,"x":68.5,"y":139,"wires":[["69653699.06399"]]},{"id":"676a938.3f64aec","type":"switch","z":"69c5ecdf.f1513c","name":"","property":"insights","propertyType":"msg","rules":[{"t":"nnull"}],"checkall":"true","outputs":1,"x":636.5,"y":141,"wires":[["67fc8e52.7235c8"]]},{"id":"44f73abb.33df64","type":"http in","z":"69c5ecdf.f1513c","name":"","url":"/teste","method":"get","swaggerDoc":"","x":70,"y":862,"wires":[["80ef94c4.579fd8"]]},{"id":"80ef94c4.579fd8","type":"http request","z":"69c5ecdf.f1513c","name":"","method":"GET","ret":"txt","url":"http://meiobit.com/358962/respawn-cancela-card-game-titanfall-frontline/","tls":"","x":231.5,"y":865,"wires":[["470d7c75.21965c"]]},{"id":"e0af275f.ca959","type":"http response","z":"69c5ecdf.f1513c","name":"","x":713.5,"y":968,"wires":[]},{"id":"c309fd8a.1a0008","type":"template","z":"69c5ecdf.f1513c","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"This is the payload: {{insights}} !\n\n","x":92.5,"y":1017,"wires":[["e0af275f.ca959"]]},{"id":"470d7c75.21965c","type":"html","z":"69c5ecdf.f1513c","name":"","tag":"div.container","ret":"text","as":"single","x":396,"y":862,"wires":[["d7fe2aa3.c85eb"]]},{"id":"d7fe2aa3.c85eb","type":"watson-translator","z":"69c5ecdf.f1513c","name":"","action":"translate","basemodel":"ar-en","domain":"news","srclang":"pt","destlang":"en","password":"","custom":"","domainhidden":"news","srclanghidden":"pt","destlanghidden":"en","basemodelhidden":"ar-en","customhidden":"","filetype":"forcedglossary","trainid":"","lgparams2":true,"ldparamshidden2":"true","x":743,"y":883,"wires":[["b6050830.f40748"]]},{"id":"e1a7e216.14d0d8","type":"debug","z":"69c5ecdf.f1513c","name":"","active":true,"console":"false","complete":"insights","x":329.5,"y":1039,"wires":[]},{"id":"16389bda.98c604","type":"inject","z":"69c5ecdf.f1513c","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":92.5,"y":927,"wires":[["80ef94c4.579fd8"]]},{"id":"43fec689.4fac8","type":"watson-personality-insights-v3","z":"69c5ecdf.f1513c","name":"","inputlang":"en","outputlang":"en","rawscores":true,"consumption":true,"x":265,"y":952,"wires":[["c309fd8a.1a0008","e1a7e216.14d0d8"]]},{"id":"b6050830.f40748","type":"function","z":"69c5ecdf.f1513c","name":"","func":"msg.payload = JSON.stringify(msg.translation.response);\nreturn msg;","outputs":1,"noerr":0,"x":460,"y":926,"wires":[["43fec689.4fac8"]]}]

Flow Info

Created 7 years, 11 months ago
Updated 7 years, 10 months ago
Rating: not yet rated

Owner

Actions

Rate:

Node Types

Core
  • debug (x1)
  • function (x5)
  • html (x2)
  • http in (x4)
  • http request (x2)
  • http response (x4)
  • inject (x1)
  • switch (x2)
  • template (x3)
Other

Tags

  • watson
  • personality
  • insights
  • translator
  • RSS
  • angular
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option