{ "kind": "open-flow-workflow", "version": 1, "name": "Send a Mandrill Template Email", "content": { "modelVersion": 14, "document": { "bindings": {}, "graph": { "nodes": { "n_c4fbcb54b783c6b9": { "name": "Run the example", "kind": "start", "inputDefs": [] }, "n_595b81b9c3bccc4e": { "inputs": { "apiKey": { "kind": "unset" }, "fromEmail": { "kind": "value", "value": "YOUR_SENDER_EMAIL" }, "toEmail": { "kind": "value", "value": "YOUR_RECIPIENT_EMAIL" }, "template": { "kind": "value", "value": "welcomeemailv2" } }, "name": "Send the template email", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "apiKey" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "fromEmail" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "toEmail" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "template" } ], "outputs": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "status" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "recipient" } ], "name": "Send the template email", "moduleId": "n_69c204f16de5fe19", "capabilities": [ { "kind": "http", "hosts": [ "mandrillapp.com" ] } ] } }, "n_61cd30fa516f0315": { "name": "Send result", "kind": "outputs", "outputDefs": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "status" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "recipient" } ], "outputMappings": { "status": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_595b81b9c3bccc4e", "output": "status" } ] }, "recipient": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_595b81b9c3bccc4e", "output": "recipient" } ] } } } }, "edges": [ { "source": "n_c4fbcb54b783c6b9", "target": "n_595b81b9c3bccc4e" }, { "source": "n_595b81b9c3bccc4e", "target": "n_61cd30fa516f0315" } ] } }, "modules": { "n_69c204f16de5fe19": { "name": "Send the template email", "imports": [], "source": "export default async function send({apiKey,fromEmail,toEmail,template},context){\n if(!apiKey||!fromEmail||!toEmail||!template||fromEmail.startsWith('YOUR_')||toEmail.startsWith('YOUR_'))throw Error('Configure the API key, sender, recipient and template');\n const message={html:'',text:'',subject:'',from_email:fromEmail,to:[{email:toEmail,type:'to'}],important:false,track_opens:false,track_clicks:false,auto_text:false,auto_html:false,inline_css:false,url_strip_qs:false,preserve_recipients:false,view_content_link:false,async:false,google_analytics_campaign:'',ip_pool:'',bcc_address:'',tracking_domain:'',signing_domain:'',return_path_domain:''};\n let r,data;try{r=await context.fetch('https://mandrillapp.com/api/1.0/messages/send-template.json',{method:'POST',headers:{'content-type':'application/json'},body:JSON.stringify({key:apiKey,template_name:template,template_content:[],message})});if(!r.ok)throw Error('HTTP error');data=await r.json()}catch{throw Error('Mailchimp Transactional request failed or has an unknown result; check the account before retrying')}\n if(!Array.isArray(data)||data.length!==1||data[0]?.email!==toEmail||!['sent','queued','scheduled','rejected','invalid'].includes(data[0]?.status))throw Error('Mailchimp Transactional returned an unknown result; check the account before retrying');const row=data[0];return{status:row.status,recipient:toEmail};\n}\n" } } }, "presentation": { "designer": { "version": 1, "flow": { "direction": "vertical" } } } }