Signalwire Simple Fax & SMS

This flow provides a web dashboard for sending and receiving Fax and simple SMS using a Signalwire account (https://www.signalwire.com).

To use this, you need a phone number with Signalwire, currently costs $0.20 per month. You will also need a webserver that is accessible on the public internet and some time understanding their API, which I found very easy to learn.

[{"id":"6635a672.c31e68","type":"tab","label":"Signalwire Fax&SMS","disabled":false,"info":""},{"id":"3c6b546a.f3522c","type":"http in","z":"6635a672.c31e68","name":"Receive a Fax Notification","url":"/rest/getfax/","method":"post","upload":false,"swaggerDoc":"","x":170,"y":460,"wires":[["4cbb2d09.443994","7a7c3c51.ceeb54"]]},{"id":"34063428.8747dc","type":"http response","z":"6635a672.c31e68","name":"","statusCode":"200","headers":{},"x":1084,"y":459,"wires":[]},{"id":"51ef06b3.b2d678","type":"ui_form","z":"6635a672.c31e68","name":"Send Fax Form","label":"Send Fax Form","group":"af4bf78f.263bb8","order":0,"width":"6","height":"2","options":[{"label":"To:","value":"to","type":"text","required":true},{"label":"Filename:","value":"file","type":"text","required":true}],"formValue":{"to":"","file":""},"payload":"","submit":"submit","cancel":"cancel","topic":"","x":140,"y":260,"wires":[["d690b8fd.7d23a8"]]},{"id":"58f4787a.e1fb98","type":"function","z":"6635a672.c31e68","name":"Build CURL Command","func":"acctsid = flow.get(\"acctsid\");\napitoken = flow.get(\"apitoken\");\nsender = flow.get(\"sender\");\nproject = flow.get(\"project\");\nmediaurl = flow.get(\"mediaurl\");\n\ncurlCommand = `curl https://${project}.signalwire.com/api/laml/2010-04-01/Accounts/{${acctsid}}/Faxes.json -X POST --data-urlencode \"From=${sender}\" --data-urlencode \"To=${msg.payload.to}\" --data-urlencode \"MediaUrl=${mediaurl}/${msg.payload.file}\" -u \"${acctsid}:${apitoken}\"`;\nmsg.payload = curlCommand;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":840,"y":301,"wires":[["95893b39.8ef998"]]},{"id":"95893b39.8ef998","type":"exec","z":"6635a672.c31e68","command":"","addpay":true,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"CURL Signalwire Send A Fax","x":1140,"y":301,"wires":[["3db00de2.5ca062"],["3db00de2.5ca062"],["3db00de2.5ca062"]]},{"id":"3db00de2.5ca062","type":"debug","z":"6635a672.c31e68","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":1390,"y":301,"wires":[]},{"id":"d690b8fd.7d23a8","type":"switch","z":"6635a672.c31e68","name":"Classify To: Number 7D, 10D, 1+10D or 011....","property":"payload.to","propertyType":"msg","rules":[{"t":"regex","v":"^\\d{7}$","vt":"str","case":false},{"t":"regex","v":"^\\d{10}$","vt":"str","case":false},{"t":"regex","v":"^1\\d{10}$","vt":"str","case":false},{"t":"regex","v":"^011\\d{13,23}","vt":"str","case":false}],"checkall":"true","repair":false,"outputs":4,"x":240,"y":306,"wires":[["65608292.b0318c"],["b2bdf9a6.34f198"],["ef338c71.ee057"],["1e638beb.683314"]]},{"id":"1e638beb.683314","type":"change","z":"6635a672.c31e68","name":"011... to E.164","rules":[{"t":"change","p":"payload.to","pt":"msg","from":"^(011)(\\d{13,23})$","fromt":"re","to":"+$2","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":580,"y":351,"wires":[["58f4787a.e1fb98"]]},{"id":"4cbb2d09.443994","type":"debug","z":"6635a672.c31e68","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":396,"y":500,"wires":[]},{"id":"7a7c3c51.ceeb54","type":"function","z":"6635a672.c31e68","name":"Create Email data with Media URL","func":"var mediaurl = msg.payload.MediaUrl;\nmsg.topic = \"A new fax message has arrived...\";\nmsg.payload = \"A new fax is availalable by clicking \" + mediaurl;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":464,"y":459,"wires":[["4d81d1f9.11512","34063428.8747dc"]]},{"id":"af63cd33.9a2a5","type":"comment","z":"6635a672.c31e68","name":"Inbound Fax Notify to E-Mail Notify","info":"","x":160,"y":426,"wires":[]},{"id":"4a40e73f.74b908","type":"comment","z":"6635a672.c31e68","name":"Sends a Fax using Signalwire API","info":"","x":150,"y":226,"wires":[]},{"id":"ff5c9c35.002cd","type":"http in","z":"6635a672.c31e68","name":"Receive an SMS Notification","url":"/rest/getsms/","method":"post","upload":false,"swaggerDoc":"","x":180,"y":601,"wires":[["3d5bf070.d538a","df80de07.f4ca4"]]},{"id":"fa0e249e.29fc18","type":"http response","z":"6635a672.c31e68","name":"","statusCode":"200","headers":{},"x":1084,"y":599,"wires":[]},{"id":"3d5bf070.d538a","type":"function","z":"6635a672.c31e68","name":"Create Email Data with SMS Message","func":"from = msg.payload.From;\nto = msg.payload.To;\nbody = msg.payload.Body;\nsegments = msg.payload.NumSegments;\nvar mediaurl = msg.payload.MediaUrl0;\n\nmsg.topic = \"A new SMS message has arrived....\";\nmsg.payload = \"A new SMS has arrived: \" + body + \" \" + mediaurl;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":474,"y":599,"wires":[["fa0e249e.29fc18","6538b29.9f47f4c","df80de07.f4ca4"]]},{"id":"a6ab14c4.569bf8","type":"comment","z":"6635a672.c31e68","name":"Inbound SMSNotify to E-Mail Notify","info":"","x":160,"y":567,"wires":[]},{"id":"c65bfabb.904bb8","type":"comment","z":"6635a672.c31e68","name":"Inbound SMS works for 1 segment and 1 mediaurl.  Need to test how many media url and not send email if the link isn't there.  Also need to wait until all media urls are available before sending one message.","info":"","x":720,"y":680,"wires":[]},{"id":"d12c9d63.e75a","type":"inject","z":"6635a672.c31e68","name":"Initialize Flow Variables","props":[{"p":"payload","v":"","vt":"date"},{"p":"topic","v":"","vt":"string"}],"repeat":"","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":150,"y":940,"wires":[["4d763ab4.b53784","2944c16b.130c3e","52e9cc3.337b734","b244abdf.e39d38","f569b19f.30a1c","3023c5bb.9b93ea"]]},{"id":"4d763ab4.b53784","type":"change","z":"6635a672.c31e68","name":"Set Account SID or Project ID (flow.acctsid)","rules":[{"t":"set","p":"acctsid","pt":"flow","to":"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":490,"y":880,"wires":[[]]},{"id":"2944c16b.130c3e","type":"change","z":"6635a672.c31e68","name":"Set API Token (flow.apitoken)","rules":[{"t":"set","p":"apitoken","pt":"flow","to":"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":440,"y":920,"wires":[[]]},{"id":"52e9cc3.337b734","type":"change","z":"6635a672.c31e68","name":"Set Area Code for 7D Calls (flow.areacode)","rules":[{"t":"set","p":"areacode","pt":"flow","to":"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":490,"y":960,"wires":[[]]},{"id":"65608292.b0318c","type":"template","z":"6635a672.c31e68","name":"7D to E.164","field":"payload.to","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"+1{{{flow.areacode}}}{{{payload.to}}}","output":"str","x":570,"y":258,"wires":[["58f4787a.e1fb98"]]},{"id":"b2bdf9a6.34f198","type":"template","z":"6635a672.c31e68","name":"10D to E.164","field":"payload.to","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"+1{{{payload.to}}}","output":"str","x":570,"y":289,"wires":[["58f4787a.e1fb98"]]},{"id":"ef338c71.ee057","type":"template","z":"6635a672.c31e68","name":"1+10Dd to E.164","field":"payload.to","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"+{{{payload.to}}}","output":"str","x":590,"y":320,"wires":[["58f4787a.e1fb98"]]},{"id":"b244abdf.e39d38","type":"change","z":"6635a672.c31e68","name":"Set Sending Number (flow.sender)","rules":[{"t":"set","p":"sender","pt":"flow","to":"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":460,"y":1000,"wires":[[]]},{"id":"6e2e3e67.44407","type":"comment","z":"6635a672.c31e68","name":"Edit these to match your Signalwire account values.","info":"","x":510,"y":800,"wires":[]},{"id":"df80de07.f4ca4","type":"debug","z":"6635a672.c31e68","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":377,"y":641,"wires":[]},{"id":"4d81d1f9.11512","type":"e-mail","z":"6635a672.c31e68","server":"smtp.gmail.com","port":"465","secure":true,"tls":false,"name":"[email protected]","dname":"Email","x":810,"y":421,"wires":[]},{"id":"6538b29.9f47f4c","type":"e-mail","z":"6635a672.c31e68","server":"smtp.gmail.com","port":"465","secure":true,"tls":false,"name":"[email protected]","dname":"Email","x":810,"y":641,"wires":[]},{"id":"31c2a4f4.eff4ec","type":"ui_form","z":"6635a672.c31e68","name":"","label":"Send SMS Form","group":"67edbd2c.d20bc4","order":0,"width":"6","height":"2","options":[{"label":"To:","value":"to","type":"text","required":true},{"label":"Message:","value":"message","type":"text","required":true}],"formValue":{"to":"","message":""},"payload":"","submit":"submit","cancel":"cancel","topic":"","x":138,"y":70,"wires":[["166243b3.bbac9c"]]},{"id":"7d7bb096.578d6","type":"function","z":"6635a672.c31e68","name":"Build CURL Command","func":"acctsid = flow.get(\"acctsid\");\napitoken = flow.get(\"apitoken\");\nsender = flow.get(\"sender\");\nproject = flow.get(\"project\");\n\ncurlCommand = 'curl https://' + project + '.signalwire.com/api/laml/2010-04-01/Accounts/{' + acctsid + '}/Messages.json -X POST --data-urlencode \"From=' + sender + '\" --data-urlencode \"Body=' + msg.payload.message + '\" --data-urlencode \"To=' + msg.payload.to + '\" -u \"' + acctsid + ':' + apitoken + '\"';\nmsg.payload = curlCommand;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":838,"y":110,"wires":[["b27093fd.e0d32"]]},{"id":"b27093fd.e0d32","type":"exec","z":"6635a672.c31e68","command":"","addpay":true,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"CURL Signalwire Send SMS","x":1138,"y":110,"wires":[["b6c06476.df7a48"],["b6c06476.df7a48"],["b6c06476.df7a48"]]},{"id":"166243b3.bbac9c","type":"switch","z":"6635a672.c31e68","name":"Classify To: Number 7D, 10D, 1+10D or 011....","property":"payload.to","propertyType":"msg","rules":[{"t":"regex","v":"^\\d{7}$","vt":"str","case":false},{"t":"regex","v":"^\\d{10}$","vt":"str","case":false},{"t":"regex","v":"^1\\d{10}$","vt":"str","case":false},{"t":"regex","v":"^011\\d{13,23}","vt":"str","case":false}],"checkall":"true","repair":false,"outputs":4,"x":238,"y":116,"wires":[["74549362.c8b73c"],["22d5703e.a4b9"],["182fd961.003037"],["9be97c80.5c12f"]]},{"id":"9be97c80.5c12f","type":"change","z":"6635a672.c31e68","name":"011... to E.164","rules":[{"t":"change","p":"payload.to","pt":"msg","from":"^(011)(\\d{13,23})$","fromt":"re","to":"+$2","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":579,"y":157,"wires":[["7d7bb096.578d6"]]},{"id":"b6c06476.df7a48","type":"debug","z":"6635a672.c31e68","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":1400,"y":111,"wires":[]},{"id":"8af6cd50.34912","type":"comment","z":"6635a672.c31e68","name":"Sends an SMS using Signalwire API","info":"","x":160,"y":35,"wires":[]},{"id":"22d5703e.a4b9","type":"template","z":"6635a672.c31e68","name":"10D to E.164","field":"payload.to","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"+1{{{payload.to}}}","output":"str","x":567,"y":99,"wires":[["7d7bb096.578d6"]]},{"id":"182fd961.003037","type":"template","z":"6635a672.c31e68","name":"1+10Dd to E.164","field":"payload.to","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"+{{{payload.to}}}","output":"str","x":588,"y":129,"wires":[["7d7bb096.578d6"]]},{"id":"f569b19f.30a1c","type":"change","z":"6635a672.c31e68","name":"Set Project Name","rules":[{"t":"set","p":"project","pt":"flow","to":"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":410,"y":840,"wires":[[]]},{"id":"3023c5bb.9b93ea","type":"change","z":"6635a672.c31e68","name":"Set Media URL (flow.mediaurl)","rules":[{"t":"set","p":"mediaurl","pt":"flow","to":"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":450,"y":1040,"wires":[[]]},{"id":"74549362.c8b73c","type":"template","z":"6635a672.c31e68","name":"7D to E.164","field":"payload.to","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"+1{{{flow.areacode}}}{{{payload.to}}}","output":"str","x":568,"y":69,"wires":[["7d7bb096.578d6"]]},{"id":"af4bf78f.263bb8","type":"ui_group","z":"","name":"Fax","tab":"c843bae9.2a7958","disp":true,"width":"6","collapse":false},{"id":"67edbd2c.d20bc4","type":"ui_group","z":"","name":"SMS","tab":"c843bae9.2a7958","disp":true,"width":"6","collapse":false},{"id":"c843bae9.2a7958","type":"ui_tab","z":"","name":"Send Fax","icon":"dashboard","disabled":false,"hidden":false}]

Flow Info

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

Owner

Actions

Rate:

Node Types

Core
  • change (x8)
  • comment (x6)
  • debug (x4)
  • exec (x2)
  • function (x4)
  • http in (x2)
  • http response (x2)
  • inject (x1)
  • switch (x2)
  • template (x6)
Other

Tags

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