{ "kind": "open-flow-workflow", "version": 1, "name": "Help Scout Inbox Reader", "content": { "modelVersion": 14, "document": { "bindings": {}, "graph": { "nodes": { "n_484bb76547e2db0f": { "name": "Read Help Scout inboxes", "kind": "start", "inputDefs": [] }, "n_89cd400d1bdb93f1": { "inputs": {}, "name": "Read first 50 Help Scout inboxes", "kind": "task", "task": { "inputs": [], "outputs": [ { "jsonSchema": { "type": "array", "items": { "type": "object", "additionalProperties": true } }, "nullable": false, "handle": "inboxes" } ], "name": "Read first 50 Help Scout inboxes", "moduleId": "n_856f69670a9673eb", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [ { "action": "helpscout.list_inboxes" } ] } ] } }, "n_2e1b282c513e9058": { "name": "Help Scout inboxes", "kind": "outputs", "outputDefs": [ { "jsonSchema": { "type": "array", "items": { "type": "object", "additionalProperties": true } }, "nullable": false, "handle": "inboxes" } ], "outputMappings": { "inboxes": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_89cd400d1bdb93f1", "output": "inboxes" } ] } } } }, "edges": [ { "source": "n_484bb76547e2db0f", "target": "n_89cd400d1bdb93f1" }, { "source": "n_89cd400d1bdb93f1", "target": "n_2e1b282c513e9058" } ] } }, "modules": { "n_856f69670a9673eb": { "name": "Read first 50 Help Scout inboxes", "imports": [], "source": "export default async function (_inputs, context) {\n const inboxes = [];\n let pageNumber = 1;\n while (true) {\n const response = await context.actions.call('helpscout.list_inboxes', { page: pageNumber });\n if (!response || !Array.isArray(response.inboxes) || response.inboxes.some((item) => !item || typeof item !== 'object' || Array.isArray(item))) throw new Error('Help Scout returned an invalid inbox collection');\n inboxes.push(...response.inboxes.slice(0, 50 - inboxes.length));\n if (inboxes.length === 50) return { inboxes };\n const page = response.page;\n if (!page || typeof page !== 'object' || Array.isArray(page) || page.number !== pageNumber || !Number.isSafeInteger(page.totalPages) || page.totalPages < 0 || (page.totalPages === 0 && (pageNumber !== 1 || response.inboxes.length !== 0))) throw new Error('Help Scout pagination metadata is missing or invalid');\n if (pageNumber >= page.totalPages) return { inboxes };\n if (response.inboxes.length === 0) throw new Error('Help Scout returned an empty page before its final page');\n pageNumber++;\n }\n}\n" } } }, "presentation": { "designer": { "version": 1, "flow": { "direction": "vertical" } } } }