{ "name": "Send a ClickSend SMS", "tags": [], "nodes": [ { "id": "send-clicksend-sms-0", "name": "When clicking ‘Test workflow’", "type": "n8n-nodes-base.manualTrigger", "position": [ -300, -100 ], "parameters": {}, "typeVersion": 1 }, { "name": "Set SMS data", "type": "n8n-nodes-base.code", "typeVersion": 2, "parameters": { "mode": "runOnceForAllItems", "jsCode": "function message({to,text}) {\n if(typeof to!=='string'||!/^\\+[1-9][0-9]{1,14}$/.test(to))throw Error('Enter an E.164 phone number');\n if(typeof text!=='string'||!text.trim())throw Error('Enter a non-empty SMS');\n return {messages:[{source:'php',body:text,to}]};\n}\n\nreturn [{json:message({to:'YOUR_PHONE_NUMBER',text:'YOUR_MESSAGE'})}];" }, "id": "send-clicksend-sms-1" }, { "id": "send-clicksend-sms-2", "name": "Send SMS", "type": "n8n-nodes-base.httpRequest", "position": [ 140, -100 ], "parameters": { "url": "https://rest.clicksend.com/v3/sms/send", "method": "POST", "options": { "redirect": { "redirect": { "followRedirects": false } } }, "jsonBody": "={{ JSON.stringify($json) }}", "sendBody": true, "sendHeaders": true, "specifyBody": "json", "authentication": "genericCredentialType", "genericAuthType": "httpBasicAuth", "headerParameters": { "parameters": [ { "name": "Content-Type", "value": " application/json" } ] } }, "typeVersion": 4.2 }, { "name": "Confirm the queued message", "type": "n8n-nodes-base.code", "typeVersion": 2, "parameters": { "mode": "runOnceForAllItems", "jsCode": "function confirm({raw}) {\n const m=raw?.data?.messages;if(raw?.response_code!=='SUCCESS'||!Array.isArray(m)||m.length!==1||m[0]?.status!=='SUCCESS'||typeof m[0].message_id!=='string'||!m[0].message_id)throw Error('ClickSend did not confirm the message was queued');\n return {messageId:m[0].message_id};\n}\n\nreturn [{json:confirm({raw:$input.first().json})}];" }, "id": "send-clicksend-sms-3" } ], "active": false, "pinData": {}, "settings": { "executionOrder": "v1" }, "connections": { "When clicking ‘Test workflow’": { "main": [ [ { "node": "Set SMS data", "type": "main", "index": 0 } ] ] }, "Set SMS data": { "main": [ [ { "node": "Send SMS", "type": "main", "index": 0 } ] ] }, "Send SMS": { "main": [ [ { "node": "Confirm the queued message", "type": "main", "index": 0 } ] ] } } }