{ "kind": "open-flow-workflow", "version": 1, "name": "Create and Update an E-goi Subscriber", "content": { "modelVersion": 14, "document": { "bindings": {}, "graph": { "nodes": { "n_d65db355b58c119f": { "name": "Enter contact details", "kind": "start", "inputDefs": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "listId" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "email" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "initialName" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "updatedName" } ] }, "n_80aedd7d8d1d7e49": { "inputs": { "listId": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_d65db355b58c119f", "output": "listId" } ] }, "email": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_d65db355b58c119f", "output": "email" } ] }, "initialName": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_d65db355b58c119f", "output": "initialName" } ] }, "updatedName": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_d65db355b58c119f", "output": "updatedName" } ] } }, "name": "Validate contact details", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "listId" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "email" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "initialName" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "updatedName" } ], "outputs": [ { "jsonSchema": { "type": "integer", "minimum": 1 }, "nullable": false, "handle": "listId" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "email" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "initialName" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "updatedName" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "url" }, { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "body" }, { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "update" } ], "name": "Validate contact details", "moduleId": "n_b5cba2c168c9b9a5", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_319855c38826befb": { "inputs": { "url": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_80aedd7d8d1d7e49", "output": "url" } ] }, "body": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_80aedd7d8d1d7e49", "output": "body" } ] }, "auth.token": { "kind": "unset" } }, "name": "Create contact", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "url" }, { "jsonSchema": {}, "nullable": true, "handle": "body" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "auth.token" } ], "outputs": [ { "jsonSchema": {}, "nullable": true, "handle": "body" }, { "jsonSchema": { "type": "integer" }, "nullable": false, "handle": "statusCode" }, { "jsonSchema": { "type": "object", "additionalProperties": { "type": "string" } }, "nullable": false, "handle": "headers" } ], "name": "Create contact", "executor": { "method": "POST", "query": { "mode": "fields", "names": [] }, "headers": { "mode": "fields", "names": [] }, "bodyFormat": "json", "authentication": { "type": "apiKey", "name": "Apikey", "in": "header" }, "responseFormat": "json", "statusPolicy": "success", "kind": "http-request" } } }, "n_7f73fcb16dd9079e": { "inputs": { "body": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_319855c38826befb", "output": "body" } ] }, "listId": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_80aedd7d8d1d7e49", "output": "listId" } ] } }, "name": "Identify the contact", "kind": "task", "task": { "inputs": [ { "jsonSchema": {}, "nullable": true, "handle": "body" }, { "jsonSchema": { "type": "integer", "minimum": 1 }, "nullable": false, "handle": "listId" } ], "outputs": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "contactId" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "url" } ], "name": "Identify the contact", "moduleId": "n_1e5aa07d90b1433d", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_20c00ad9ea009224": { "inputs": { "url": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_7f73fcb16dd9079e", "output": "url" } ] }, "body": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_80aedd7d8d1d7e49", "output": "update" } ] }, "auth.token": { "kind": "unset" } }, "name": "Update first name", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "url" }, { "jsonSchema": {}, "nullable": true, "handle": "body" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "auth.token" } ], "outputs": [ { "jsonSchema": { "type": "string" }, "nullable": true, "handle": "body" }, { "jsonSchema": { "type": "integer" }, "nullable": false, "handle": "statusCode" }, { "jsonSchema": { "type": "object", "additionalProperties": { "type": "string" } }, "nullable": false, "handle": "headers" } ], "name": "Update first name", "executor": { "method": "PATCH", "query": { "mode": "fields", "names": [] }, "headers": { "mode": "fields", "names": [] }, "bodyFormat": "json", "authentication": { "type": "apiKey", "name": "Apikey", "in": "header" }, "responseFormat": "text", "statusPolicy": "success", "kind": "http-request" } } }, "n_e251f06983f18b50": { "inputs": { "url": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_7f73fcb16dd9079e", "output": "url" } ] }, "auth.token": { "kind": "unset" } }, "name": "Read the contact", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "url" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "auth.token" } ], "outputs": [ { "jsonSchema": {}, "nullable": true, "handle": "body" }, { "jsonSchema": { "type": "integer" }, "nullable": false, "handle": "statusCode" }, { "jsonSchema": { "type": "object", "additionalProperties": { "type": "string" } }, "nullable": false, "handle": "headers" } ], "name": "Read the contact", "executor": { "method": "GET", "query": { "mode": "fields", "names": [] }, "headers": { "mode": "fields", "names": [] }, "bodyFormat": "none", "authentication": { "type": "apiKey", "name": "Apikey", "in": "header" }, "responseFormat": "json", "statusPolicy": "success", "kind": "http-request" } } }, "n_26d3e7e96249ed6c": { "inputs": { "body": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_e251f06983f18b50", "output": "body" } ] }, "contactId": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_7f73fcb16dd9079e", "output": "contactId" } ] }, "email": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_80aedd7d8d1d7e49", "output": "email" } ] }, "updatedName": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_80aedd7d8d1d7e49", "output": "updatedName" } ] } }, "name": "Verify the contact", "kind": "task", "task": { "inputs": [ { "jsonSchema": {}, "nullable": true, "handle": "body" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "contactId" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "email" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "updatedName" } ], "outputs": [ { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "contact" } ], "name": "Verify the contact", "moduleId": "n_95ef78ce6abe1756", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_a2e0ca3dac089433": { "name": "Saved contact", "kind": "outputs", "outputDefs": [ { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "contact" } ], "outputMappings": { "contact": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_26d3e7e96249ed6c", "output": "contact" } ] } } } }, "edges": [ { "source": "n_d65db355b58c119f", "target": "n_80aedd7d8d1d7e49" }, { "source": "n_80aedd7d8d1d7e49", "target": "n_319855c38826befb" }, { "source": "n_319855c38826befb", "target": "n_7f73fcb16dd9079e" }, { "source": "n_7f73fcb16dd9079e", "target": "n_20c00ad9ea009224" }, { "source": "n_20c00ad9ea009224", "target": "n_e251f06983f18b50" }, { "source": "n_e251f06983f18b50", "target": "n_26d3e7e96249ed6c" }, { "source": "n_26d3e7e96249ed6c", "target": "n_a2e0ca3dac089433" } ] } }, "modules": { "n_b5cba2c168c9b9a5": { "name": "Validate contact details", "imports": [], "source": "export default function setup({listId,email,initialName,updatedName}){if(typeof listId!=='string'||!/^\\d+$/.test(listId)||!Number.isSafeInteger(Number(listId))||Number(listId)<1)throw Error('Enter a numeric list ID');if(typeof email!=='string'||!/^\\S+@\\S+\\.\\S+$/.test(email.trim()))throw Error('Enter a valid email');if(typeof initialName!=='string'||!initialName.trim()||typeof updatedName!=='string'||!updatedName.trim())throw Error('Enter both names');return {listId:Number(listId),email:email.trim(),initialName:initialName.trim(),updatedName:updatedName.trim(),url:'https://api.egoiapp.com/lists/'+listId+'/contacts',body:{base:{email:email.trim(),first_name:initialName.trim()},extra:[]},update:{base:{first_name:updatedName.trim()},extra:[]}};}\n" }, "n_1e5aa07d90b1433d": { "name": "Identify the contact", "imports": [], "source": "export default function created({body,listId}){const id=body?.contact_id;if(typeof id!=='string'||!/^[a-f0-9]{10}$/i.test(id))throw Error('Contact ID missing or invalid');return {contactId:id,url:'https://api.egoiapp.com/lists/'+listId+'/contacts/'+id};}\n" }, "n_95ef78ce6abe1756": { "name": "Verify the contact", "imports": [], "source": "export default function confirm({body,contactId,email,updatedName}){const c=body?.base;if(!c||c.contact_id!==contactId||typeof c.email!=='string'||c.email.toLowerCase()!==email.toLowerCase()||c.first_name!==updatedName)throw Error('Returned contact does not match');return {contact:body};}\n" } } }, "presentation": { "designer": { "version": 1, "flow": { "direction": "vertical" } } } }