April
28th,
2015
Today I was looking at some of the new Watson nodes for Node-RED created by my colleague James Thomas and was presently surprised how easy it was to start using the Watson services in Node-RED. (I am not sure why, I was surprised everything in Node-RED seems to be easy) For one of my upcoming presentations I put together a simple flow for a REST API that uses the Watson Machine Translation service in order to translate text POSTed to an API endpoint. Below is a video I created of how easy this was to do.
If you are interested in adding the flow to your Node-RED instance copy the below JSON and import into a sheet. Note: you will need a Watson Machine Translation service bound to your Node-RED app in order for the flow to work.
[ { "id": "e317bb59.6978a", "type": "http in", "name": "", "url": "/translate", "method": "post", "x": 216, "y": 115, "z": "be5832fc.ca9ca8", "wires": [ [ "e7f0c9c6.0a838" ] ] }, { "id": "e7f0c9c6.0a838", "type": "function", "name": "", "func": "msg.payload = msg.req.body.txt;\nmsg.lang = msg.req.body.lang;\nreturn msg;", "outputs": 1, "valid": true, "x": 454, "y": 113, "z": "be5832fc.ca9ca8", "wires": [ [ "8b9210eb.1de0e8" ] ] }, { "id": "8b9210eb.1de0e8", "type": "watson-translate", "name": "", "language": "", "x": 665, "y": 106, "z": "be5832fc.ca9ca8", "wires": [ [ "1f345415.c4af44" ] ] }, { "id": "1f345415.c4af44", "type": "http response", "name": "", "x": 892, "y": 101, "z": "be5832fc.ca9ca8", "wires": [] } ]