{ "kind": "open-flow-workflow", "version": 1, "name": "Customer.io Customer to Manual Segment", "content": { "modelVersion": 14, "document": { "bindings": {}, "graph": { "nodes": { "n_4f3dc68fe2443b23": { "name": "Add a customer", "kind": "start", "inputDefs": [] }, "n_9f1831533caba4fd": { "inputs": { "customerId": { "kind": "value", "value": "2" }, "segmentId": { "kind": "value", "value": "YOUR_SEGMENT_ID" }, "name": { "kind": "value", "value": "n8n" } }, "name": "Configure customer and segment", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "string", "minLength": 1 }, "nullable": false, "handle": "customerId" }, { "jsonSchema": { "type": "string", "minLength": 1 }, "nullable": false, "handle": "segmentId" }, { "jsonSchema": { "type": "string", "minLength": 1 }, "nullable": false, "handle": "name" } ], "outputs": [ { "jsonSchema": { "type": "string", "pattern": "\\S", "minLength": 1, "description": "The Customer.io person identifier in the path. Use the person's id, email address, or cio_id value with the cio_ prefix." }, "nullable": false, "handle": "customerId" }, { "jsonSchema": { "type": "object", "properties": { "id": { "type": "string", "description": "The Customer.io id attribute to assign to the person." }, "email": { "type": "string", "format": "email", "description": "The Customer.io email attribute to assign to the person." }, "anonymous_id": { "type": "string", "description": "The anonymous identifier to associate with the person." }, "created_at": { "type": "integer", "description": "The Unix timestamp when the person was created." }, "_timestamp": { "type": "integer", "description": "The Unix timestamp for when this attribute update occurred." }, "_update": { "type": "boolean", "description": "Whether Customer.io should only update an existing person instead of creating a new one." }, "unsubscribed": { "type": "boolean", "description": "Whether the person is unsubscribed from all messages." } }, "additionalProperties": { "description": "One custom Customer.io profile attribute value." }, "description": "The Customer.io profile attributes to assign to the person." }, "nullable": false, "handle": "attributes" }, { "jsonSchema": { "type": "string", "minLength": 1 }, "nullable": false, "handle": "endpoint" }, { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "body" } ], "name": "Configure customer and segment", "moduleId": "n_83137691f4a0d487", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_8ab0b39a837676db": { "inputs": { "identifier": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_9f1831533caba4fd", "output": "customerId" } ] }, "attributes": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_9f1831533caba4fd", "output": "attributes" } ] } }, "name": "Identify the customer", "kind": "task", "task": { "inputs": [ { "description": "The Customer.io person identifier in the path. Use the person's id, email address, or cio_id value with the cio_ prefix.", "jsonSchema": { "type": "string", "pattern": "\\S", "minLength": 1, "description": "The Customer.io person identifier in the path. Use the person's id, email address, or cio_id value with the cio_ prefix." }, "nullable": false, "handle": "identifier" }, { "description": "The Customer.io profile attributes to assign to the person.", "jsonSchema": { "type": "object", "properties": { "id": { "type": "string", "description": "The Customer.io id attribute to assign to the person." }, "email": { "type": "string", "format": "email", "description": "The Customer.io email attribute to assign to the person." }, "anonymous_id": { "type": "string", "description": "The anonymous identifier to associate with the person." }, "created_at": { "type": "integer", "description": "The Unix timestamp when the person was created." }, "_timestamp": { "type": "integer", "description": "The Unix timestamp for when this attribute update occurred." }, "_update": { "type": "boolean", "description": "Whether Customer.io should only update an existing person instead of creating a new one." }, "unsubscribed": { "type": "boolean", "description": "Whether the person is unsubscribed from all messages." } }, "additionalProperties": { "description": "One custom Customer.io profile attribute value." }, "description": "The Customer.io profile attributes to assign to the person." }, "nullable": false, "handle": "attributes" } ], "outputs": [ { "description": "Whether Customer.io accepted the request.", "jsonSchema": { "type": "boolean", "description": "Whether Customer.io accepted the request." }, "nullable": false, "handle": "ok" } ], "name": "Identify the customer", "executor": { "kind": "connector", "action": "customerio.identify_customer" } } }, "n_5dfdc206492a7a55": { "inputs": { "ok": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_8ab0b39a837676db", "output": "ok" } ] }, "endpoint": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_9f1831533caba4fd", "output": "endpoint" } ] }, "body": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_9f1831533caba4fd", "output": "body" } ] } }, "name": "Prepare segment request", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "boolean", "description": "Whether Customer.io accepted the request." }, "nullable": false, "handle": "ok" }, { "jsonSchema": { "type": "string", "minLength": 1 }, "nullable": false, "handle": "endpoint" }, { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "body" } ], "outputs": [ { "jsonSchema": { "type": "string", "minLength": 1 }, "nullable": false, "handle": "endpoint" }, { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "body" } ], "name": "Prepare segment request", "moduleId": "n_29071af9619efe9e", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_9970617f09f22f32": { "inputs": { "endpoint": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_5dfdc206492a7a55", "output": "endpoint" } ] }, "body": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_5dfdc206492a7a55", "output": "body" } ] } }, "name": "Add to the manual segment", "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": "Add to the manual segment", "executor": { "providerId": "customerio", "method": "POST", "query": { "mode": "fields", "names": [] }, "headers": { "mode": "fields", "names": [] }, "bodyFormat": "json", "kind": "connector-proxy" } } }, "n_c63db8154d15802f": { "inputs": { "statusCode": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_9970617f09f22f32", "output": "statusCode" } ] }, "bodyEncoding": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_9970617f09f22f32", "output": "bodyEncoding" } ] }, "customerId": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_9f1831533caba4fd", "output": "customerId" } ] } }, "name": "Confirm segment acceptance", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "integer" }, "nullable": false, "handle": "statusCode" }, { "jsonSchema": { "const": "base64" }, "nullable": true, "handle": "bodyEncoding" }, { "jsonSchema": { "type": "string", "minLength": 1 }, "nullable": false, "handle": "customerId" } ], "outputs": [ { "jsonSchema": { "type": "string", "minLength": 1 }, "nullable": false, "handle": "customerId" }, { "jsonSchema": { "type": "boolean" }, "nullable": false, "handle": "accepted" } ], "name": "Confirm segment acceptance", "moduleId": "n_ae705ba0f081698d", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_ad5f6b50960f1fc2": { "name": "Request accepted", "kind": "outputs", "outputDefs": [ { "jsonSchema": { "type": "string", "minLength": 1 }, "nullable": false, "handle": "customerId" }, { "jsonSchema": { "type": "boolean" }, "nullable": false, "handle": "accepted" } ], "outputMappings": { "customerId": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_c63db8154d15802f", "output": "customerId" } ] }, "accepted": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_c63db8154d15802f", "output": "accepted" } ] } } } }, "edges": [ { "source": "n_4f3dc68fe2443b23", "target": "n_9f1831533caba4fd" }, { "source": "n_9f1831533caba4fd", "target": "n_8ab0b39a837676db" }, { "source": "n_8ab0b39a837676db", "target": "n_5dfdc206492a7a55" }, { "source": "n_5dfdc206492a7a55", "target": "n_9970617f09f22f32" }, { "source": "n_9970617f09f22f32", "target": "n_c63db8154d15802f" }, { "source": "n_c63db8154d15802f", "target": "n_ad5f6b50960f1fc2" } ] } }, "modules": { "n_83137691f4a0d487": { "name": "Configure customer and segment", "imports": [], "source": "export default function customerioPlan({customerId,segmentId,name}){\n if(typeof customerId!=='string'||!customerId.trim())throw Error('Enter a customer ID');\n if(typeof segmentId!=='string'||!/^\\d+$/.test(segmentId)||Number(segmentId)<1||Number(segmentId)>2147483647)throw Error('Enter a positive manual segment ID');\n if(typeof name!=='string'||!name)throw Error('Enter the Name value');\n return{customerId,attributes:{data:{Name:name}},endpoint:'/api/v1/segments/'+segmentId+'/add_customers',body:{ids:[customerId]}};\n}\n" }, "n_29071af9619efe9e": { "name": "Prepare segment request", "imports": [], "source": "export default function customerioConfirm({ok,endpoint,body}){if(ok!==true)throw Error('Customer identification was not accepted');return{endpoint,body};}\n" }, "n_ae705ba0f081698d": { "name": "Confirm segment acceptance", "imports": [], "source": "export default function customerioFinish({statusCode,bodyEncoding,customerId}){if(!Number.isInteger(statusCode)||statusCode<200||statusCode>=300||bodyEncoding!=null)throw Error('Segment request failed');return{customerId,accepted:true};}\n" } } }, "presentation": { "designer": { "version": 1, "flow": { "direction": "vertical" } } } }