{ "name": "Send a Text-to-Speech Call with ClickSend", "tags": [], "nodes": [ { "id": "send-a-text-to-speech-call-with-clicksend-0", "name": "On form submission", "type": "n8n-nodes-base.formTrigger", "position": [ -300, -100 ], "parameters": { "options": { "path": "send-voice-call" }, "formTitle": "Send Voice Message", "formFields": { "values": [ { "fieldType": "textarea", "fieldLabel": "Body", "placeholder": "Body (max. 600 chars)", "requiredField": true }, { "fieldLabel": "To", "placeholder": "+39xxxxxxxxxx", "requiredField": true }, { "fieldType": "dropdown", "fieldLabel": "Voice", "fieldOptions": { "values": [ { "option": "male" }, { "option": "female" } ] }, "requiredField": true }, { "fieldType": "dropdown", "fieldLabel": "Lang", "fieldOptions": { "values": [ { "option": "en-us" }, { "option": "it-it" }, { "option": "en-au" }, { "option": "en-gb" }, { "option": "de-de" }, { "option": "es-es" }, { "option": "fr-fr" }, { "option": "is-is" }, { "option": "da-dk" }, { "option": "nl-nl" }, { "option": "pl-pl" }, { "option": "pt-br" }, { "option": "ru-ru" } ] }, "requiredField": true } ] } }, "typeVersion": 2.2 }, { "name": "Prepare the voice call", "type": "n8n-nodes-base.code", "typeVersion": 2, "parameters": { "mode": "runOnceForEachItem", "jsCode": "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\nreturn {json:prepareVoice({request:$json}).request};" }, "id": "send-a-text-to-speech-call-with-clicksend-1" }, { "id": "send-a-text-to-speech-call-with-clicksend-2", "name": "Send the voice call", "type": "n8n-nodes-base.httpRequest", "position": [ -40, -100 ], "parameters": { "method": "POST", "url": "https://rest.clicksend.com/v3/voice/send", "authentication": "genericCredentialType", "genericAuthType": "httpBasicAuth", "sendBody": true, "contentType": "json", "specifyBody": "json", "jsonBody": "={{ $json }}", "options": {} }, "typeVersion": 4.2 } ], "active": false, "pinData": {}, "settings": { "executionOrder": "v1" }, "connections": { "On form submission": { "main": [ [ { "node": "Prepare the voice call", "type": "main", "index": 0 } ] ] }, "Prepare the voice call": { "main": [ [ { "node": "Send the voice call", "type": "main", "index": 0 } ] ] } } }