Json2XML

ligação

[{"id":"ec63c84d.6e9a68","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"d5e8dfc2.90838","type":"json2xml","z":"ec63c84d.6e9a68","name":"J2XML TwiML Response","root":"Response","x":690,"y":200,"wires":[["a1701358.a073b","fabb0729.f299b8"]]},{"id":"a1701358.a073b","type":"http response","z":"ec63c84d.6e9a68","name":"Send TwiML","x":931,"y":200,"wires":[]},{"id":"17e74cc7.e78d23","type":"http in","z":"ec63c84d.6e9a68","name":"TwilioVoice incoming","url":"/twiliovoice","method":"post","upload":false,"swaggerDoc":"","x":94,"y":197,"wires":[["e5d452a6.a0d89","3daa93de.a8491c"]]},{"id":"e5d452a6.a0d89","type":"function","z":"ec63c84d.6e9a68","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":406,"y":199,"wires":[["d5e8dfc2.90838"]]},{"id":"48b71175.c0355","type":"http in","z":"ec63c84d.6e9a68","name":"TwilioVoice Handle","url":"/twilioivr","method":"post","x":98,"y":277,"wires":[["26fa8b18.0c4234","af7abee6.c73ec"]]},{"id":"26fa8b18.0c4234","type":"function","z":"ec63c84d.6e9a68","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":406,"y":286,"wires":[["d5e8dfc2.90838"],["f95c7359.42644","2a0470f9.1b286"]]},{"id":"fabb0729.f299b8","type":"debug","z":"ec63c84d.6e9a68","name":"","active":true,"complete":false,"x":925,"y":307,"wires":[]},{"id":"af7abee6.c73ec","type":"debug","z":"ec63c84d.6e9a68","name":"","active":true,"complete":false,"x":395,"y":343,"wires":[]},{"id":"f95c7359.42644","type":"mqtt out","z":"ec63c84d.6e9a68","name":"Post message","topic":"","broker":"d8b83be0.2bafa8","x":701,"y":308,"wires":[]},{"id":"2a0470f9.1b286","type":"debug","z":"ec63c84d.6e9a68","name":"","active":true,"console":"false","complete":"true","x":675,"y":354,"wires":[]},{"id":"3daa93de.a8491c","type":"debug","z":"ec63c84d.6e9a68","name":"","active":true,"console":false,"complete":false,"x":403,"y":131,"wires":[]},{"id":"d8b83be0.2bafa8","type":"mqtt-broker","broker":"localhost","port":"1883","clientid":""}]

Flow Info

Created 7 years, 4 months ago
Rating: not yet rated

Owner

Actions

Rate:

Node Types

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

Tags

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