Created
September 11, 2015 13:47
-
-
Save davidgeorgeuk/c44211d19dd78c4484e9 to your computer and use it in GitHub Desktop.
Node-RED Q&A plus Twilio SMS Demo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[{ | |
"id": "546be34d.bd9d64", | |
"type": "watson-question-answer", | |
"name": "", | |
"output": "top", | |
"corpus": "healthcare", | |
"x": 377, | |
"y": 115, | |
"z": "45fca0cc.ba036", | |
"wires": [ | |
["603748a2.f78d5"] | |
] | |
}, { | |
"id": "603748a2.f78d5", | |
"type": "switch", | |
"name": "Check Confidence", | |
"property": "confidence", | |
"rules": [{ | |
"t": "gte", | |
"v": ".35" | |
}, { | |
"t": "else" | |
}], | |
"checkall": "false", | |
"outputs": 2, | |
"x": 144, | |
"y": 209, | |
"z": "45fca0cc.ba036", | |
"wires": [ | |
["ccac57c6.9db9f"], | |
["3158bd80.e62d62"] | |
] | |
}, { | |
"id": "3158bd80.e62d62", | |
"type": "function", | |
"name": "Assign 'not sure' message", | |
"func": "// Assign a 'not sure' message\nmsg.payload = 'Sorry, I\\'m not sure about the answer to that question.'\n\nreturn msg;", | |
"outputs": 1, | |
"noerr": 0, | |
"x": 276, | |
"y": 281, | |
"z": "45fca0cc.ba036", | |
"wires": [ | |
["ccac57c6.9db9f"] | |
] | |
}, { | |
"id": "ccac57c6.9db9f", | |
"type": "function", | |
"name": "Convert to SMS length", | |
"func": "/* If the message has more than 160 characters\n truncate it and add elipses */\nvar responseBody = msg.payload; \nif(responseBody.length > 160){\n responseBody = responseBody.substr(0,157) + '...';\n}\n\n/* Create a TwiML response */\nvar msgObj = {\n 'Response':{\n 'Message':responseBody\n }\n};\n\nmsg.payload = msgObj;\n\nreturn msg;", | |
"outputs": 1, | |
"noerr": 0, | |
"x": 405, | |
"y": 203, | |
"z": "45fca0cc.ba036", | |
"wires": [ | |
["c5df5b2a.2c60a"] | |
] | |
}, { | |
"id": "b371e316.ba0e98", | |
"type": "http in", | |
"name": "", | |
"url": "/twilio", | |
"method": "post", | |
"swaggerDoc": "", | |
"x": 88, | |
"y": 47, | |
"z": "45fca0cc.ba036", | |
"wires": [ | |
["d8b093a0.286d3"] | |
] | |
}, { | |
"id": "c5df5b2a.2c60a", | |
"type": "xml", | |
"name": "Convert to TwiML", | |
"attr": "$", | |
"chr": "_", | |
"x": 145, | |
"y": 363, | |
"z": "45fca0cc.ba036", | |
"wires": [ | |
["6fdc241a.55dcec"] | |
] | |
}, { | |
"id": "6fdc241a.55dcec", | |
"type": "http response", | |
"name": "Respond to Twilio", | |
"x": 372, | |
"y": 363, | |
"z": "45fca0cc.ba036", | |
"wires": [] | |
}, { | |
"id": "d8b093a0.286d3", | |
"type": "function", | |
"name": "Store SMS details", | |
"func": "// Store the SMS details we need for the response\nmsg.from = msg.payload.From;\nmsg.payload = msg.payload.Body;\n\nreturn msg;", | |
"outputs": 1, | |
"noerr": 0, | |
"x": 259, | |
"y": 47, | |
"z": "45fca0cc.ba036", | |
"wires": [ | |
["546be34d.bd9d64"] | |
] | |
}] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment