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":"f54ed66b.d61f68","type":"cloudant out","z":"5e7ef766.e32e98","name":"DB","cloudant":"","database":"posts","service":"eriknetonr-cloudantNoSQLDB","payonly":false,"operation":"insert","x":887,"y":111.5,"wires":[]},{"id":"e1756bd.35bf198","type":"http in","z":"5e7ef766.e32e98","name":"","url":"/show","method":"get","swaggerDoc":"","x":84.9999885559082,"y":459.9999933242798,"wires":[["453164c6.e3bd4c"]]},{"id":"8055e8f2.e9c898","type":"cloudant in","z":"5e7ef766.e32e98","name":"DB","cloudant":"","database":"posts","service":"eriknetonr-cloudantNoSQLDB","search":"_all_","design":"","index":"","x":463.49998474121094,"y":494,"wires":[["fdf22288.cfc89"]]},{"id":"e3873f09.02635","type":"feedparse","z":"5e7ef766.e32e98","name":"FeedParser","url":"change this to your feed","interval":"15","x":89.5,"y":43,"wires":[["ae65cdd9.ac2c8"]]},{"id":"4a6bbc48.962004","type":"watson-personality-insights-v3","z":"5e7ef766.e32e98","name":"","inputlang":"en","outputlang":"pt-br","rawscores":true,"consumption":true,"x":336.5,"y":118,"wires":[["d14a9140.de9ac"]]},{"id":"a375327d.087e4","type":"http response","z":"5e7ef766.e32e98","name":"","x":778,"y":496.75,"wires":[]},{"id":"fdf22288.cfc89","type":"template","z":"5e7ef766.e32e98","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":629,"y":510.25,"wires":[["a375327d.087e4"]]},{"id":"1da3526e.0fea3e","type":"watson-translator","z":"5e7ef766.e32e98","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":131.5,"y":116,"wires":[["4a6bbc48.962004"]]},{"id":"1e716148.0889bf","type":"http in","z":"5e7ef766.e32e98","name":"","url":"/news","method":"get","swaggerDoc":"","x":84.5,"y":303,"wires":[["beca8431.a9bd28"]]},{"id":"73b7d53.991ea2c","type":"http response","z":"5e7ef766.e32e98","name":"","x":631.5,"y":347,"wires":[]},{"id":"beca8431.a9bd28","type":"template","z":"5e7ef766.e32e98","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":318.5,"y":317,"wires":[["73b7d53.991ea2c"]]},{"id":"9417ea41.deb1b8","type":"http in","z":"5e7ef766.e32e98","name":"","url":"/results","method":"get","swaggerDoc":"","x":92.5,"y":207,"wires":[["e82eea.08623118"]]},{"id":"26d7b06b.53201","type":"http response","z":"5e7ef766.e32e98","name":"","x":691.5,"y":223,"wires":[]},{"id":"e82eea.08623118","type":"cloudant in","z":"5e7ef766.e32e98","name":"","cloudant":"","database":"posts","service":"eriknetonr-cloudantNoSQLDB","search":"_all_","design":"","index":"","x":426.5,"y":213,"wires":[["26d7b06b.53201"]]},{"id":"7ca60abe.669284","type":"http request","z":"5e7ef766.e32e98","name":"","method":"GET","ret":"txt","url":"","tls":"","x":408.5,"y":42,"wires":[["1da3526e.0fea3e"]]},{"id":"ae65cdd9.ac2c8","type":"function","z":"5e7ef766.e32e98","name":"","func":"msg.url = msg.topic;\nreturn msg;","outputs":1,"noerr":0,"x":241.5,"y":43,"wires":[["7ca60abe.669284"]]},{"id":"d14a9140.de9ac","type":"function","z":"5e7ef766.e32e98","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;\nreturn msg;\n","outputs":1,"noerr":0,"x":600.5,"y":121,"wires":[["f54ed66b.d61f68"]]},{"id":"453164c6.e3bd4c","type":"function","z":"5e7ef766.e32e98","name":"","func":"msg.payload = {limit:10};\nreturn msg;","outputs":1,"noerr":0,"x":248.5,"y":476,"wires":[["8055e8f2.e9c898"]]}]
erikneto

Flow Info

created 3 months, 2 weeks ago

Node Types

Core
  • feedparse (x1)
  • function (x3)
  • http in (x3)
  • http request (x1)
  • http response (x3)
  • template (x2)
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