Watson Workspace will no longer be available after February 28, 2019. Learn more.

Developers

Use node-red on bluemix for building a template for application integrations to Watson Workspaces

Comments

1 comment

  • Avatar
    Bernd Gewehr

    This solved my issue:

     

        [{"id":"8293a6ad.d66198","type":"inject","z":"90f1749a.99cbe8","name":"Message to be posted","topic":"","payload":"message","payloadType":"str","repeat":"","crontab":"","once":false,"x":260,"y":900,"wires":[["20b0bce7.1350bc"]]},{"id":"fb46a168.a74b2","type":"http request","z":"90f1749a.99cbe8","name":"","method":"POST","ret":"txt","url":"{{{servername}}}/v1/spaces/{{{spaceid}}}/messages","tls":"","x":750,"y":900,"wires":[["2ee0b357.7be35c"]]},{"id":"2ee0b357.7be35c","type":"debug","z":"90f1749a.99cbe8","name":"","active":true,"console":"false","complete":"true","x":930,"y":900,"wires":[]},{"id":"20b0bce7.1350bc","type":"function","z":"90f1749a.99cbe8","name":"setToken&Message","func":"msg.headers = {\n    \"content-type\": \"application/json\",\n    'jwt' : global.get(\"token\"), // token retrieved from global variable - Need to run OAuth Token flow first\n}\nmsg.spaceid=\"580e30c3e4b0e0daf7d77b87\"; // id of the space in which you want to send a message\n\nvar body = msg.payload; //retrieved from injector\n\nvar messageData ={\n    type: \"appMessage\",\n    version: 1.0,\n    annotations:  [{\n        type: \"generic\",\n        version: 1.0,\n        color: \"#FF0000\",\n        title: \"application name\",\n        text: body,\n        actor: \n            {\n              name: \"user name\",\n              avatar: \"\",\n              url: \"\"\n        }\n    }]\n};\nmsg.payload = messageData;\nmsg.servername=global.get(\"servername\"); // get servername from global variable\nreturn msg;","outputs":1,"noerr":0,"x":530,"y":900,"wires":[["fb46a168.a74b2"]]},{"id":"ee987eb3.0e4158","type":"comment","z":"90f1749a.99cbe8","name":"WWS PostMessage","info":"","x":630,"y":840,"wires":[]}]

Please sign in to leave a comment.