{ "kind": "open-flow-workflow", "version": 1, "name": "Send a Text-to-Speech Call with ClickSend", "content": { "modelVersion": 14, "document": { "bindings": {}, "graph": { "nodes": { "n_5a9ab524546fd64b": { "name": "Receive voice call details", "kind": "webhook", "bodyFields": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "Body" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "To" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "Voice" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "Lang" } ], "method": "POST" }, "n_1447ed0598ff3288": { "inputs": { "request": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_5a9ab524546fd64b", "output": "body" } ] } }, "name": "Prepare the voice call", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "request" } ], "outputs": [ { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "request" } ], "name": "Prepare the voice call", "moduleId": "n_d6f1c54ed684dfe2", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_028965460f7f46ad": { "inputs": { "endpoint": { "kind": "value", "value": "/voice/send" }, "body": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_1447ed0598ff3288", "output": "request" } ] } }, "name": "Send the voice call", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "endpoint" }, { "jsonSchema": {}, "nullable": true, "handle": "body" } ], "outputs": [ { "jsonSchema": {}, "nullable": true, "handle": "body" }, { "jsonSchema": { "type": "integer" }, "nullable": false, "handle": "statusCode" }, { "jsonSchema": { "type": "object", "additionalProperties": { "type": "string" } }, "nullable": false, "handle": "headers" }, { "jsonSchema": { "const": "base64" }, "nullable": true, "handle": "bodyEncoding" } ], "name": "Send the voice call", "executor": { "providerId": "clicksend", "method": "POST", "query": { "mode": "fields", "names": [] }, "headers": { "mode": "fields", "names": [] }, "bodyFormat": "json", "kind": "connector-proxy" } } } }, "edges": [ { "source": "n_5a9ab524546fd64b", "target": "n_1447ed0598ff3288" }, { "source": "n_1447ed0598ff3288", "target": "n_028965460f7f46ad" } ] } }, "modules": { "n_d6f1c54ed684dfe2": { "name": "Prepare the voice call", "imports": [], "source": "export default function prepareVoice({request}) {\n const {Body:body,To:to,Voice:voice,Lang:language}=request??{}; let lang=language;\n if(typeof body!=='string'||!body.trim()||Array.from(body).length>600)throw Error('Enter a message of up to 600 characters');\n if(typeof to!=='string'||!/^\\+[1-9]\\d{7,14}$/.test(to))throw Error('Enter a phone number in E.164 format');\n if(!['male','female'].includes(voice))throw Error('Choose male or female');\n if(typeof lang!=='string')throw Error('Choose a language');\n lang=lang.trim();\n if(!['en-us','it-it','en-au','en-gb','de-de','es-es','fr-fr','is-is','da-dk','nl-nl','pl-pl','pt-br','ru-ru'].includes(lang))throw Error('Choose a supported language');\n return {request:{messages:[{source:'n8n',body,to,voice,lang,machine_detection:1}]}};\n}\n" } } }, "presentation": { "designer": { "version": 1, "flow": { "direction": "vertical" } } } }