IcanGoWithTheFlow

Learning - Just will try to connect some services and see what I get

[{"id":"3fd7311e.c028ce","type":"mqtt-broker","broker":"localhost","port":"1883","clientid":""},{"id":"698c27e6.9673d8","type":"json2xml","name":"J2XML TwiML Response","root":"Response","x":717,"y":283,"z":"8a59ed8a.75a61","wires":[["f767454d.0898b8","c8cdcfd4.37323"]]},{"id":"f767454d.0898b8","type":"http response","name":"Send TwiML","x":958,"y":283,"z":"8a59ed8a.75a61","wires":[]},{"id":"6c74d317.938b2c","type":"http in","name":"TwilioVoice incoming","url":"/twiliovoice","method":"post","x":121,"y":280,"z":"8a59ed8a.75a61","wires":[["88efab86.771058","52a0fad4.ad5f04"]]},{"id":"88efab86.771058","type":"function","name":"Process Call","func":"// Create JSON object for payload response\n\nvar messageObj = { \"Gather\": [{ \"@\": { \"action\": \"http://yourhost:port/twilioivr\",\"numDigits\":\"1\"},\n\t\t \"Say\":  [ { \"@\": { \"voice\": \"woman\" }, \"#\": \"Welcome to Node-Red. For power usage press 1. To ring the bell press 2. For anything else press 3\" }]}],\n\t\t \"Say\":  [ { \"@\": { \"voice\": \"woman\" }, \"#\": \"You didnt press a key, goodbye\"}]};\n/* The sort of example XML we are trying to create is shown below:\n\n    <Gather action=\"handle-user-input.php\" numDigits=\"1\">\n        <Say>Welcome to TPS.</Say>\n        <Say>For store hours, press 1.</Say>\n        <Say>To speak to an agent, press 2.</Say>\n        <Say>To check your package status, press 3.</Say>\n    </Gather>\n    <!-- If customer doesn't input anything, prompt and try again. -->\n    <Say>Sorry, I didn't get your response.</Say>\n*/\nmsg.payload = messageObj;\nreturn msg;","outputs":1,"x":433,"y":282,"z":"8a59ed8a.75a61","wires":[["698c27e6.9673d8"]]},{"id":"49cc3109.b633d","type":"http in","name":"TwilioVoice Handle","url":"/twilioivr","method":"post","x":125,"y":360,"z":"8a59ed8a.75a61","wires":[["b07a8d73.4f857","21e1cdbe.de1e32"]]},{"id":"b07a8d73.4f857","type":"function","name":"Handle Voice","func":"// Use 2 outputs, 2nd is for mqtt topic/payload combination\n// Could be useful to post other caller info to a topic\nvar mqttOut = null;\nvar responseMsg = \"\";\n\nvar name = \"wholehouse\";\nvar reading = context.global[name];\nvar digit = msg.payload.Digits;\nif( digit == \"1\" ) {\n\tresponseMsg = \"Your power usage is now \" + reading + \" Watts.\";\n} else if( digit == \"2\" ) {\n\tresponseMsg = \"Ring my bell.\";\n\tmqttOut = {topic: \"bellduino/ring\", payload: \"ringmybell\" };\n} else {\n\tresponseMsg = \"You pressed \" + digit;\n}\n\n// Create JSON object for payload response\nvar messageObj = { \"Say\": [ { \"@\": { \"voice\": \"woman\" }, \"#\": responseMsg } ] } ;\n\nmsg.payload = messageObj;\nreturn [msg, mqttOut];","outputs":"2","x":433,"y":369,"z":"8a59ed8a.75a61","wires":[["698c27e6.9673d8"],["753eb82a.8ac148","a7f09d49.580f6"]]},{"id":"c8cdcfd4.37323","type":"debug","name":"","active":true,"complete":false,"x":952,"y":390,"z":"8a59ed8a.75a61","wires":[]},{"id":"21e1cdbe.de1e32","type":"debug","name":"","active":true,"complete":false,"x":422,"y":426,"z":"8a59ed8a.75a61","wires":[]},{"id":"753eb82a.8ac148","type":"mqtt out","name":"Post message","topic":"","broker":"3fd7311e.c028ce","x":728,"y":391,"z":"8a59ed8a.75a61","wires":[]},{"id":"a7f09d49.580f6","type":"debug","name":"","active":true,"console":"false","complete":"true","x":702,"y":437,"z":"8a59ed8a.75a61","wires":[]},{"id":"52a0fad4.ad5f04","type":"debug","name":"","active":true,"console":false,"complete":false,"x":430,"y":214,"z":"8a59ed8a.75a61","wires":[]}]
emenni

Flow Info

created 3 weeks, 6 days ago

Node Types

Core
  • debug (x4)
  • function (x2)
  • http in (x2)
  • http response (x1)
  • mqtt out (x1)
  • mqtt-broker (x1)
Other
  • json2xml (x1)

Tags

Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option