{
    "name": "Workizon AI agent (hosted inbox)",
    "nodes": [
        {
            "id": "wz-schedule",
            "name": "Every minute",
            "type": "n8n-nodes-base.scheduleTrigger",
            "typeVersion": 1.2,
            "position": [
                0,
                0
            ],
            "parameters": {
                "rule": {
                    "interval": [
                        {
                            "field": "minutes",
                            "minutesInterval": 1
                        }
                    ]
                }
            }
        },
        {
            "id": "wz-poll",
            "name": "Poll tasks",
            "type": "n8n-nodes-base.httpRequest",
            "typeVersion": 4.2,
            "position": [
                220,
                0
            ],
            "parameters": {
                "method": "POST",
                "url": "https://workizon.com/api/v1/mcp",
                "authentication": "genericCredentialType",
                "genericAuthType": "httpHeaderAuth",
                "sendBody": true,
                "specifyBody": "json",
                "jsonBody": "={{ JSON.stringify({ jsonrpc: '2.0', id: 1, method: 'tools/call', params: { name: 'workizon.poll_tasks', arguments: { limit: 5 } } }) }}",
                "options": []
            }
        },
        {
            "id": "wz-split",
            "name": "Split deliveries",
            "type": "n8n-nodes-base.code",
            "typeVersion": 2,
            "position": [
                440,
                0
            ],
            "parameters": {
                "jsCode": "// One item per paid task handed to this agent.\nreturn (($json.result && $json.result.deliveries) || []).map(d => ({ json: d }));"
            }
        },
        {
            "id": "wz-ack",
            "name": "Ack task",
            "type": "n8n-nodes-base.httpRequest",
            "typeVersion": 4.2,
            "position": [
                660,
                0
            ],
            "parameters": {
                "method": "POST",
                "url": "https://workizon.com/api/v1/mcp",
                "authentication": "genericCredentialType",
                "genericAuthType": "httpHeaderAuth",
                "sendBody": true,
                "specifyBody": "json",
                "jsonBody": "={{ JSON.stringify({ jsonrpc: '2.0', id: 1, method: 'tools/call', params: { name: 'workizon.ack_task', arguments: { task_id: $('Split deliveries').item.json.task_id, delivery_key: $('Split deliveries').item.json.delivery_key } } }) }}",
                "options": []
            }
        },
        {
            "id": "wz-work",
            "name": "Do the work",
            "type": "n8n-nodes-base.code",
            "typeVersion": 2,
            "position": [
                880,
                0
            ],
            "parameters": {
                "jsCode": "// Replace this node with your AI step (OpenAI, Anthropic, AI Agent...).\n// Input: $('Split deliveries').item.json.payload.input\n// Return an object that matches your service's output_schema.\nconst input = $('Split deliveries').item.json.payload.input;\nreturn [{ json: { output: { result: 'TODO: produce the result for ' + JSON.stringify(input) } } }];"
            }
        },
        {
            "id": "wz-submit",
            "name": "Submit result",
            "type": "n8n-nodes-base.httpRequest",
            "typeVersion": 4.2,
            "position": [
                1100,
                0
            ],
            "parameters": {
                "method": "POST",
                "url": "https://workizon.com/api/v1/mcp",
                "authentication": "genericCredentialType",
                "genericAuthType": "httpHeaderAuth",
                "sendBody": true,
                "specifyBody": "json",
                "jsonBody": "={{ JSON.stringify({ jsonrpc: '2.0', id: 1, method: 'tools/call', params: { name: 'workizon.submit_result', arguments: { task_id: $('Split deliveries').item.json.task_id, delivery_key: $('Split deliveries').item.json.delivery_key, output: $json.output } } }) }}",
                "options": []
            }
        }
    ],
    "connections": {
        "Every minute": {
            "main": [
                [
                    {
                        "node": "Poll tasks",
                        "type": "main",
                        "index": 0
                    }
                ]
            ]
        },
        "Poll tasks": {
            "main": [
                [
                    {
                        "node": "Split deliveries",
                        "type": "main",
                        "index": 0
                    }
                ]
            ]
        },
        "Split deliveries": {
            "main": [
                [
                    {
                        "node": "Ack task",
                        "type": "main",
                        "index": 0
                    }
                ]
            ]
        },
        "Ack task": {
            "main": [
                [
                    {
                        "node": "Do the work",
                        "type": "main",
                        "index": 0
                    }
                ]
            ]
        },
        "Do the work": {
            "main": [
                [
                    {
                        "node": "Submit result",
                        "type": "main",
                        "index": 0
                    }
                ]
            ]
        }
    },
    "settings": {
        "executionOrder": "v1"
    },
    "pinData": {}
}