{ "kind": "open-flow-workflow", "version": 1, "name": "Mailjet Email Sender", "content": { "modelVersion": 14, "document": { "bindings": {}, "graph": { "nodes": { "n_9cd281a0103d62c8": { "name": "Enter email details", "kind": "start", "inputDefs": [ { "jsonSchema": { "type": "string", "format": "email" }, "nullable": false, "handle": "fromEmail" }, { "jsonSchema": { "type": "string", "format": "email" }, "nullable": false, "handle": "toEmail" }, { "jsonSchema": { "type": "string", "minLength": 1 }, "nullable": false, "handle": "subject" }, { "jsonSchema": { "type": "string", "minLength": 1 }, "nullable": false, "handle": "text" } ] }, "n_ca78f8871ca01a40": { "inputs": { "fromEmail": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_9cd281a0103d62c8", "output": "fromEmail" } ] }, "toEmail": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_9cd281a0103d62c8", "output": "toEmail" } ] }, "subject": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_9cd281a0103d62c8", "output": "subject" } ] }, "text": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_9cd281a0103d62c8", "output": "text" } ] } }, "name": "Prepare plain-text email", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "string", "format": "email" }, "nullable": false, "handle": "fromEmail" }, { "jsonSchema": { "type": "string", "format": "email" }, "nullable": false, "handle": "toEmail" }, { "jsonSchema": { "type": "string", "minLength": 1 }, "nullable": false, "handle": "subject" }, { "jsonSchema": { "type": "string", "minLength": 1 }, "nullable": false, "handle": "text" } ], "outputs": [ { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "body" } ], "name": "Prepare plain-text email", "moduleId": "n_9f8c989d66e2ec6c", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_55b346810f4ee13b": { "inputs": { "url": { "kind": "value", "value": "https://api.mailjet.com/v3.1/send" }, "body": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_ca78f8871ca01a40", "output": "body" } ] }, "auth.username": { "kind": "unset" }, "auth.password": { "kind": "unset" } }, "name": "Send Mailjet email", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "url" }, { "jsonSchema": {}, "nullable": true, "handle": "body" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "auth.username" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "auth.password" } ], "outputs": [ { "jsonSchema": {}, "nullable": true, "handle": "body" }, { "jsonSchema": { "type": "integer" }, "nullable": false, "handle": "statusCode" }, { "jsonSchema": { "type": "object", "additionalProperties": { "type": "string" } }, "nullable": false, "handle": "headers" } ], "name": "Send Mailjet email", "executor": { "method": "POST", "query": { "mode": "fields", "names": [] }, "headers": { "mode": "fields", "names": [] }, "bodyFormat": "json", "authentication": { "type": "basic" }, "responseFormat": "json", "statusPolicy": "success", "kind": "http-request" } } }, "n_e5f4eefbbed5802b": { "inputs": { "body": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_55b346810f4ee13b", "output": "body" } ] }, "statusCode": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_55b346810f4ee13b", "output": "statusCode" } ] } }, "name": "Confirm email acceptance", "kind": "task", "task": { "inputs": [ { "jsonSchema": {}, "nullable": true, "handle": "body" }, { "jsonSchema": { "type": "integer" }, "nullable": false, "handle": "statusCode" } ], "outputs": [ { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "message" } ], "name": "Confirm email acceptance", "moduleId": "n_a5a58d32447e8621", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_c442e1de57ad98f1": { "name": "Accepted email result", "kind": "outputs", "outputDefs": [ { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "message" } ], "outputMappings": { "message": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_e5f4eefbbed5802b", "output": "message" } ] } } } }, "edges": [ { "source": "n_9cd281a0103d62c8", "target": "n_ca78f8871ca01a40" }, { "source": "n_ca78f8871ca01a40", "target": "n_55b346810f4ee13b" }, { "source": "n_55b346810f4ee13b", "target": "n_e5f4eefbbed5802b" }, { "source": "n_e5f4eefbbed5802b", "target": "n_c442e1de57ad98f1" } ] } }, "modules": { "n_9f8c989d66e2ec6c": { "name": "Prepare plain-text email", "imports": [], "source": "export default function emailRequest({ fromEmail, toEmail, subject, text }) {\n for (const [name, value] of Object.entries({ fromEmail, toEmail, subject, text })) if (typeof value !== 'string' || !value.trim()) throw new Error(name + ' is required');\n return { body: { Messages: [{ From: { Email: fromEmail }, To: [{ Email: toEmail }], Subject: subject, TextPart: text }], SandboxMode: false } };\n}\n" }, "n_a5a58d32447e8621": { "name": "Confirm email acceptance", "imports": [], "source": "function readMailjetMessage(message) {\n if (!message || typeof message !== 'object' || Array.isArray(message) || message.Status !== 'success') throw new Error('Mailjet did not accept the message');\n if (!Array.isArray(message.To) || message.To.length !== 1 || message.To.some((recipient) => !recipient || typeof recipient.Email !== 'string' || !((typeof recipient.MessageID === 'number' && Number.isFinite(recipient.MessageID)) || (typeof recipient.MessageID === 'string' && recipient.MessageID)) || typeof recipient.MessageUUID !== 'string' || !recipient.MessageUUID)) throw new Error('Mailjet returned no accepted recipient identifier');\n return message;\n}\nexport default function emailResult({ body, statusCode, bodyEncoding }) {\n if (statusCode !== 200 || bodyEncoding) throw new Error('Mailjet did not return a completed Send API result (HTTP ' + statusCode + ')');\n if (!body || !Array.isArray(body.Messages) || body.Messages.length !== 1) throw new Error('Mailjet returned an unexpected message batch');\n return { message: readMailjetMessage(body.Messages[0]) };\n}\n" } } }, "presentation": { "designer": { "version": 1, "flow": { "direction": "vertical" } } } }