{ "kind": "open-flow-workflow", "version": 1, "name": "Airtable Users to Mailchimp Subscribers", "content": { "modelVersion": 14, "document": { "bindings": {}, "graph": { "nodes": { "n_b196116e97d4fca6": { "name": "Daily at 14:00 UTC", "kind": "cron", "cronTimes": [ { "type": "cron", "expression": "0 14 * * *", "timezone": "UTC" } ] }, "n_0294216f82bb376c": { "inputs": { "baseId": { "kind": "value", "value": "YOUR_AIRTABLE_BASE_ID" }, "tableIdOrName": { "kind": "value", "value": "Users" }, "fields": { "kind": "value", "value": [ "Name", "Email", "Interest" ] }, "pageSize": { "kind": "value", "value": 100 }, "offset": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_90dc7f053fa132fb", "output": "offset" } ] } }, "name": "Read Airtable users", "kind": "task", "task": { "inputs": [ { "description": "Base ID in the format appXXXXXXXXXXXXXX.", "jsonSchema": { "type": "string", "minLength": 1, "description": "Base ID in the format appXXXXXXXXXXXXXX." }, "nullable": false, "handle": "baseId" }, { "description": "Table ID or table name accepted by the Airtable path parameter.", "jsonSchema": { "type": "string", "minLength": 1, "description": "Table ID or table name accepted by the Airtable path parameter." }, "nullable": false, "handle": "tableIdOrName" }, { "description": "View name or view ID used by Airtable to filter and sort results.", "jsonSchema": { "type": "string", "minLength": 1, "description": "View name or view ID used by Airtable to filter and sort results." }, "nullable": true, "handle": "view", "value": null }, { "description": "Field names or field IDs to include in the Airtable response.", "jsonSchema": { "type": "array", "items": { "type": "string", "minLength": 1, "description": "An array item." }, "minItems": 1, "description": "Field names or field IDs to include in the Airtable response." }, "nullable": true, "handle": "fields", "value": null }, { "description": "Sort rules applied by Airtable in order.", "jsonSchema": { "type": "array", "items": { "type": "object", "properties": { "field": { "type": "string", "minLength": 1, "description": "Field name or field ID used by Airtable for sorting." }, "direction": { "type": "string", "enum": [ "asc", "desc" ], "description": "Sort direction accepted by Airtable." } }, "required": [ "field" ], "additionalProperties": false, "description": "Sort rule accepted by the Airtable list records endpoint." }, "minItems": 1, "description": "Sort rules applied by Airtable in order." }, "nullable": true, "handle": "sort", "value": null }, { "description": "Formula string evaluated by Airtable to filter matching records.", "jsonSchema": { "type": "string", "minLength": 1, "description": "Formula string evaluated by Airtable to filter matching records." }, "nullable": true, "handle": "filterByFormula", "value": null }, { "description": "Maximum total number of records to return before Airtable stops pagination.", "jsonSchema": { "type": "integer", "minimum": 1, "description": "Maximum total number of records to return before Airtable stops pagination." }, "nullable": true, "handle": "maxRecords", "value": null }, { "description": "Number of records to return per page.", "jsonSchema": { "type": "integer", "minimum": 1, "maximum": 100, "description": "Number of records to return per page." }, "nullable": true, "handle": "pageSize", "value": null }, { "description": "Opaque pagination cursor returned by a previous Airtable response.", "jsonSchema": { "type": "string", "minLength": 1, "description": "Opaque pagination cursor returned by a previous Airtable response." }, "nullable": true, "handle": "offset", "value": null }, { "description": "Cell format accepted by Airtable for read operations.", "jsonSchema": { "type": "string", "enum": [ "json", "string" ], "description": "Cell format accepted by Airtable for read operations." }, "nullable": true, "handle": "cellFormat", "value": null }, { "description": "Timezone string sent to Airtable when cellFormat is string.", "jsonSchema": { "type": "string", "minLength": 1, "description": "Timezone string sent to Airtable when cellFormat is string." }, "nullable": true, "handle": "timeZone", "value": null }, { "description": "User locale sent to Airtable when cellFormat is string.", "jsonSchema": { "type": "string", "minLength": 1, "description": "User locale sent to Airtable when cellFormat is string." }, "nullable": true, "handle": "userLocale", "value": null }, { "description": "Whether Airtable should return field IDs instead of field names in record objects.", "jsonSchema": { "type": "boolean", "description": "Whether Airtable should return field IDs instead of field names in record objects." }, "nullable": true, "handle": "returnFieldsByFieldId", "value": null }, { "description": "Whether Airtable should return date dependency metadata for linked record fields.", "jsonSchema": { "type": "boolean", "description": "Whether Airtable should return date dependency metadata for linked record fields." }, "nullable": true, "handle": "includeDateDependencyMetadata", "value": null }, { "description": "Record metadata fields to include in Airtable list records responses.", "jsonSchema": { "type": "array", "items": { "const": "commentCount", "description": "An array item." }, "minItems": 1, "description": "Record metadata fields to include in Airtable list records responses." }, "nullable": true, "handle": "recordMetadata", "value": null } ], "outputs": [ { "description": "Records returned by Airtable.", "jsonSchema": { "type": "array", "items": { "type": "object", "properties": { "id": { "type": "string", "description": "Record ID." }, "createdTime": { "type": "string", "description": "Record creation timestamp returned by Airtable." }, "fields": { "type": "object", "additionalProperties": { "description": "A record value." }, "description": "Record fields keyed by field name or field ID." }, "commentCount": { "type": "integer", "description": "Comment count returned by Airtable when enabled on the endpoint." } }, "required": [ "id", "fields" ], "additionalProperties": true, "description": "Airtable record." }, "description": "Records returned by Airtable." }, "nullable": false, "handle": "records" }, { "description": "Pagination cursor for the next page of records, or null when unavailable.", "jsonSchema": { "type": [ "string", "null" ], "description": "Pagination cursor for the next page of records, or null when unavailable." }, "nullable": true, "handle": "offset" } ], "name": "Read Airtable users", "executor": { "kind": "connector", "action": "airtable.list_records" } } }, "n_90dc7f053fa132fb": { "inputs": { "records": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_0294216f82bb376c", "output": "records" } ] }, "offset": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_0294216f82bb376c", "output": "offset" } ] }, "previousState": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_90dc7f053fa132fb", "output": "state" } ] } }, "name": "Collect the next page", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "array", "items": { "type": "object", "properties": { "id": { "type": "string", "description": "Record ID." }, "createdTime": { "type": "string", "description": "Record creation timestamp returned by Airtable." }, "fields": { "type": "object", "additionalProperties": { "description": "A record value." }, "description": "Record fields keyed by field name or field ID." }, "commentCount": { "type": "integer", "description": "Comment count returned by Airtable when enabled on the endpoint." } }, "required": [ "id", "fields" ], "additionalProperties": true, "description": "Airtable record." }, "description": "Records returned by Airtable." }, "nullable": false, "handle": "records" }, { "jsonSchema": { "type": [ "string", "null" ], "description": "Pagination cursor for the next page of records, or null when unavailable." }, "nullable": true, "handle": "offset" }, { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": true, "handle": "previousState" } ], "outputs": [ { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "state" }, { "jsonSchema": { "type": "string", "minLength": 1 }, "nullable": false, "handle": "offset" }, { "jsonSchema": { "type": "boolean" }, "nullable": false, "handle": "more" } ], "name": "Collect the next page", "moduleId": "n_87b2f9eb0e540a9a", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_b3903b3f0ebf22ec": { "inputs": {}, "name": "More Airtable pages?", "kind": "condition", "matchMode": "first", "cases": [ { "output": "more", "groups": [ { "expressions": [ { "left": { "kind": "source", "source": { "kind": "node", "nodeId": "n_90dc7f053fa132fb", "output": "more" } }, "operator": "isTrue" } ] } ] } ] }, "n_e2a54ecc2ba717f3": { "inputs": { "pageState": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_90dc7f053fa132fb", "output": "state" } ] }, "previousState": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_e2a54ecc2ba717f3", "output": "state" } ] }, "listId": { "kind": "value", "value": "YOUR_MAILCHIMP_AUDIENCE_ID" } }, "name": "Prepare the next subscriber", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "pageState" }, { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": true, "handle": "previousState" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "listId" } ], "outputs": [ { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "state" }, { "jsonSchema": { "type": "boolean" }, "nullable": false, "handle": "more" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "endpoint" }, { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "body" }, { "jsonSchema": { "type": "integer" }, "nullable": false, "handle": "count" } ], "name": "Prepare the next subscriber", "moduleId": "n_7c6771b13a55218b", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_0ca68bbfc9cc470d": { "inputs": {}, "name": "More users?", "kind": "condition", "matchMode": "first", "cases": [ { "output": "more", "groups": [ { "expressions": [ { "left": { "kind": "source", "source": { "kind": "node", "nodeId": "n_e2a54ecc2ba717f3", "output": "more" } }, "operator": "isTrue" } ] } ] } ] }, "n_688fdf2ffc89923f": { "inputs": { "endpoint": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_e2a54ecc2ba717f3", "output": "endpoint" } ] }, "body": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_e2a54ecc2ba717f3", "output": "body" } ] } }, "name": "Add the subscriber", "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 the subscriber", "executor": { "providerId": "mailchimp", "method": "POST", "query": { "mode": "fields", "names": [] }, "headers": { "mode": "fields", "names": [] }, "bodyFormat": "json", "kind": "connector-proxy" } } }, "n_3494efea3410157a": { "inputs": { "body": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_688fdf2ffc89923f", "output": "body" } ] }, "statusCode": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_688fdf2ffc89923f", "output": "statusCode" } ] }, "bodyEncoding": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_688fdf2ffc89923f", "output": "bodyEncoding" } ] } }, "name": "Check the member response", "kind": "task", "task": { "inputs": [ { "jsonSchema": {}, "nullable": true, "handle": "body" }, { "jsonSchema": { "type": "integer" }, "nullable": false, "handle": "statusCode" }, { "jsonSchema": { "const": "base64" }, "nullable": true, "handle": "bodyEncoding" } ], "outputs": [ { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "member" } ], "name": "Check the member response", "moduleId": "n_4765c9ca516b5e6f", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_bcaba2d93bfedb3e": { "name": "Added subscriber count", "kind": "outputs", "outputDefs": [ { "jsonSchema": { "type": "integer" }, "nullable": false, "handle": "count" } ], "outputMappings": { "count": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_e2a54ecc2ba717f3", "output": "count" } ] } } } }, "edges": [ { "source": "n_b196116e97d4fca6", "target": "n_0294216f82bb376c" }, { "source": "n_0294216f82bb376c", "target": "n_90dc7f053fa132fb" }, { "source": "n_90dc7f053fa132fb", "target": "n_b3903b3f0ebf22ec" }, { "source": "n_b3903b3f0ebf22ec", "target": "n_0294216f82bb376c", "sourceHandle": "more" }, { "source": "n_b3903b3f0ebf22ec", "target": "n_e2a54ecc2ba717f3", "sourceHandle": "otherwise" }, { "source": "n_e2a54ecc2ba717f3", "target": "n_0ca68bbfc9cc470d" }, { "source": "n_0ca68bbfc9cc470d", "target": "n_688fdf2ffc89923f", "sourceHandle": "more" }, { "source": "n_688fdf2ffc89923f", "target": "n_3494efea3410157a" }, { "source": "n_3494efea3410157a", "target": "n_e2a54ecc2ba717f3" }, { "source": "n_0ca68bbfc9cc470d", "target": "n_bcaba2d93bfedb3e", "sourceHandle": "otherwise" } ] } }, "modules": { "n_87b2f9eb0e540a9a": { "name": "Collect the next page", "imports": [], "source": "export default function collectUsers({records,offset,previousState}) {\n if (!Array.isArray(records)) throw new Error('Missing Airtable records');\n const state=previousState ?? {records:[],seen:[]};\n if (!Array.isArray(state.records)||!Array.isArray(state.seen)) throw new Error('Invalid pagination state');\n if (offset!==null && (typeof offset!=='string'||!offset||state.seen.includes(offset))) throw new Error('Invalid or repeated Airtable offset');\n const all=[...state.records,...records];\n if(offset===null) for(const r of all){const f=r?.fields;if(typeof f?.Email!=='string'||!f.Email.trim()||typeof f?.Name!=='string'||!f.Name.trim())throw new Error('Airtable record requires text Email and Name');}\n return {state:{records:all,seen:offset===null?state.seen:[...state.seen,offset]},offset:offset??'unused',more:offset!==null};\n}\n" }, "n_7c6771b13a55218b": { "name": "Prepare the next subscriber", "imports": [], "source": "export default function nextMember({pageState,previousState,listId}) {\n if(typeof listId!=='string'||!listId.trim()||listId==='YOUR_MAILCHIMP_AUDIENCE_ID') throw new Error('Configure the Mailchimp audience ID');\n const records=pageState?.records,index=previousState?.index??0;\n if(!Array.isArray(records)||!Number.isInteger(index)||index<0||index>records.length) throw new Error('Invalid subscriber state');\n if(index===records.length) return {state:{index},more:false,endpoint:'/unused',body:{},count:index};\n const fields=records[index]?.fields,email=fields?.Email,name=fields?.Name;\n if(typeof email!=='string'||!email.trim()||typeof name!=='string'||!name.trim()) throw new Error('Airtable record requires text Email and Name');\n return {state:{index:index+1},more:true,endpoint:'/lists/'+encodeURIComponent(listId)+'/members',body:{email_address:email,status:'subscribed',merge_fields:{FNAME:name},tags:['Interest']},count:index+1};\n}\n" }, "n_4765c9ca516b5e6f": { "name": "Check the member response", "imports": [], "source": "export default function memberResult({ body, statusCode, bodyEncoding }) {\n if (statusCode !== 200 || bodyEncoding) throw new Error('Mailchimp did not return a completed member result (HTTP ' + statusCode + ')');\n if (!body || typeof body !== 'object' || Array.isArray(body) || typeof body.id !== 'string' || !body.id || typeof body.email_address !== 'string' || typeof body.status !== 'string') throw new Error('Mailchimp returned an unexpected member response');\n return { member: body };\n}\n" } } }, "presentation": { "designer": { "version": 1, "flow": { "direction": "vertical" } } } }