Skip to content

Instantly share code, notes, and snippets.

@data-henrik
Created January 24, 2017 16:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save data-henrik/a0cd99b3f27782e02ec397d7784f8baf to your computer and use it in GitHub Desktop.
Save data-henrik/a0cd99b3f27782e02ec397d7784f8baf to your computer and use it in GitHub Desktop.
Watson Conversation with Twitter

Combines Twitter input and output with Watson Conversation. Use Twitter with your chatbot.

[
{
"id": "46d9cb.778d1634",
"type": "watson-conversation-v1",
"z": "f1222972.dba8d8",
"name": "",
"workspaceid": "",
"multiuser": false,
"context": true,
"x": 640,
"y": 227,
"wires": [
[
"5775b1a4.cd812",
"10317b1a.994a25"
]
]
},
{
"id": "7f769d7f.f923e4",
"type": "twitter in",
"z": "f1222972.dba8d8",
"twitter": "",
"tags": "",
"user": "false",
"name": "Twitter Input",
"topic": "tweets",
"inputs": 1,
"x": 220,
"y": 227,
"wires": [
[
"c3488e5.a85f27",
"92c4a2af.308ec"
]
]
},
{
"id": "c3488e5.a85f27",
"type": "function",
"z": "f1222972.dba8d8",
"name": "Prepare input",
"func": "if (typeof msg.tweet.retweeted_status == 'undefined')\n{\n\tif (typeof msg.tweet.lang != 'undefined')\n {\n lang=msg.tweet.lang;\n }\n\t\n\tvar msg = {\n\t\tuser: msg.tweet.user.screen_name,\n\t\tlang: lang,\n\t\ttweet: msg.tweet.text,\n\t\tpayload: msg.tweet.text\n\t};\n\tflow.set('tweet',msg);\n}\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 451,
"y": 225,
"wires": [
[
"46d9cb.778d1634"
]
]
},
{
"id": "8be44abc.899b88",
"type": "twitter out",
"z": "f1222972.dba8d8",
"twitter": "",
"name": "Twitter output",
"x": 1101,
"y": 217,
"wires": []
},
{
"id": "92c4a2af.308ec",
"type": "debug",
"z": "f1222972.dba8d8",
"name": "",
"active": true,
"console": "false",
"complete": "false",
"x": 454,
"y": 139,
"wires": []
},
{
"id": "5775b1a4.cd812",
"type": "debug",
"z": "f1222972.dba8d8",
"name": "",
"active": true,
"console": "false",
"complete": "false",
"x": 913,
"y": 299,
"wires": []
},
{
"id": "10317b1a.994a25",
"type": "function",
"z": "f1222972.dba8d8",
"name": "process result",
"func": "var tweet=flow.get('tweet');\nmsg.payload=\"@\"+tweet.user+\" \"+msg.payload.output.text+\" \"+tweet.lang+\" \"+Date.now();\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 869,
"y": 212,
"wires": [
[
"8be44abc.899b88",
"94f1ab71.a8fe28"
]
]
},
{
"id": "94f1ab71.a8fe28",
"type": "debug",
"z": "f1222972.dba8d8",
"name": "",
"active": true,
"console": "false",
"complete": "false",
"x": 1055,
"y": 147,
"wires": []
}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment