{ "kind": "open-flow-workflow", "version": 1, "name": "Send a ClickSend SMS", "content": { "modelVersion": 14, "document": { "bindings": {}, "graph": { "nodes": { "n_63773cdf0590f288": { "name": "Enter SMS details", "kind": "start", "inputDefs": [ { "jsonSchema": { "type": "string", "minLength": 1 }, "nullable": false, "handle": "to" }, { "jsonSchema": { "type": "string", "minLength": 1 }, "nullable": false, "handle": "text" } ] }, "n_246b2ed3d7e1bc14": { "inputs": { "to": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_63773cdf0590f288", "output": "to" } ] }, "text": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_63773cdf0590f288", "output": "text" } ] } }, "name": "Validate SMS details", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "string", "minLength": 1 }, "nullable": false, "handle": "to" }, { "jsonSchema": { "type": "string", "minLength": 1 }, "nullable": false, "handle": "text" } ], "outputs": [ { "jsonSchema": { "type": "array", "items": { "type": "object", "properties": { "body": { "type": "string", "minLength": 1, "description": "The SMS body to send." }, "to": { "type": "string", "minLength": 1, "description": "The recipient phone number in E.164 format." }, "list_id": { "type": "string", "minLength": 1, "description": "The ClickSend contact list ID to send to." }, "from": { "type": "string", "minLength": 1, "description": "The sender ID, dedicated number, own number, or alpha tag." }, "source": { "type": "string", "minLength": 1, "description": "The source application name passed to ClickSend." }, "schedule": { "type": "integer", "description": "The Unix timestamp when ClickSend should send the SMS." }, "custom_string": { "type": "string", "minLength": 1, "description": "A custom string returned by ClickSend with message callbacks." }, "contact_id": { "type": "string", "minLength": 1, "description": "The ClickSend contact ID associated with the recipient." }, "country": { "type": "string", "minLength": 1, "description": "The two-letter destination country code." }, "from_email": { "type": "string", "minLength": 1, "description": "The email address that should receive SMS replies." }, "exclude_no_sender_id_recipients": { "type": "boolean", "description": "Whether ClickSend should exclude recipients that cannot receive this sender ID." } }, "required": [ "body" ], "additionalProperties": false, "description": "One SMS message to send through ClickSend." }, "minItems": 1, "description": "SMS messages to send or price." }, "nullable": false, "handle": "messages" } ], "name": "Validate SMS details", "moduleId": "n_f0797e4d6927925d", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_e84c7f62b0195d9c": { "inputs": { "messages": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_246b2ed3d7e1bc14", "output": "messages" } ] } }, "name": "Send the SMS", "kind": "task", "task": { "inputs": [ { "description": "SMS messages to send or price.", "jsonSchema": { "type": "array", "items": { "type": "object", "properties": { "body": { "type": "string", "minLength": 1, "description": "The SMS body to send." }, "to": { "type": "string", "minLength": 1, "description": "The recipient phone number in E.164 format." }, "list_id": { "type": "string", "minLength": 1, "description": "The ClickSend contact list ID to send to." }, "from": { "type": "string", "minLength": 1, "description": "The sender ID, dedicated number, own number, or alpha tag." }, "source": { "type": "string", "minLength": 1, "description": "The source application name passed to ClickSend." }, "schedule": { "type": "integer", "description": "The Unix timestamp when ClickSend should send the SMS." }, "custom_string": { "type": "string", "minLength": 1, "description": "A custom string returned by ClickSend with message callbacks." }, "contact_id": { "type": "string", "minLength": 1, "description": "The ClickSend contact ID associated with the recipient." }, "country": { "type": "string", "minLength": 1, "description": "The two-letter destination country code." }, "from_email": { "type": "string", "minLength": 1, "description": "The email address that should receive SMS replies." }, "exclude_no_sender_id_recipients": { "type": "boolean", "description": "Whether ClickSend should exclude recipients that cannot receive this sender ID." } }, "required": [ "body" ], "additionalProperties": false, "description": "One SMS message to send through ClickSend." }, "minItems": 1, "description": "SMS messages to send or price." }, "nullable": false, "handle": "messages" }, { "description": "Whether ClickSend should shorten URLs in the SMS body.", "jsonSchema": { "type": "boolean", "description": "Whether ClickSend should shorten URLs in the SMS body." }, "nullable": true, "handle": "shorten_urls", "value": null } ], "outputs": [ { "description": "The response code returned by ClickSend.", "jsonSchema": { "type": "string", "description": "The response code returned by ClickSend." }, "nullable": true, "handle": "responseCode" }, { "description": "The response message returned by ClickSend.", "jsonSchema": { "type": "string", "description": "The response message returned by ClickSend." }, "nullable": true, "handle": "responseMessage" }, { "description": "The data payload returned by ClickSend.", "jsonSchema": { "description": "The data payload returned by ClickSend." }, "nullable": true, "handle": "data" }, { "description": "The raw ClickSend response object.", "jsonSchema": { "type": "object", "properties": {}, "additionalProperties": true, "description": "The raw ClickSend response object." }, "nullable": false, "handle": "raw" } ], "name": "Send the SMS", "executor": { "kind": "connector", "action": "clicksend.send_sms" } } }, "n_57f736569df6fa99": { "inputs": { "raw": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_e84c7f62b0195d9c", "output": "raw" } ] } }, "name": "Confirm the queued message", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "object", "properties": {}, "additionalProperties": true, "description": "The raw ClickSend response object." }, "nullable": false, "handle": "raw" } ], "outputs": [ { "jsonSchema": { "type": "string", "minLength": 1 }, "nullable": false, "handle": "messageId" } ], "name": "Confirm the queued message", "moduleId": "n_a65d744ba73003cb", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_05e90abe2607c371": { "name": "Queued message ID", "kind": "outputs", "outputDefs": [ { "jsonSchema": { "type": "string", "minLength": 1 }, "nullable": false, "handle": "messageId" } ], "outputMappings": { "messageId": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_57f736569df6fa99", "output": "messageId" } ] } } } }, "edges": [ { "source": "n_63773cdf0590f288", "target": "n_246b2ed3d7e1bc14" }, { "source": "n_246b2ed3d7e1bc14", "target": "n_e84c7f62b0195d9c" }, { "source": "n_e84c7f62b0195d9c", "target": "n_57f736569df6fa99" }, { "source": "n_57f736569df6fa99", "target": "n_05e90abe2607c371" } ] } }, "modules": { "n_f0797e4d6927925d": { "name": "Validate SMS details", "imports": [], "source": "export default 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" }, "n_a65d744ba73003cb": { "name": "Confirm the queued message", "imports": [], "source": "export default 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" } } }, "presentation": { "designer": { "version": 1, "flow": { "direction": "vertical" } } } }