{
  "name": "Generate branded PDF reports from incoming emails using Autype and OpenRouter",
  "nodes": [
    {
      "id": "9bb1c1b3-916f-47da-9596-f531966726af",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -17424,
        2688
      ],
      "parameters": {
        "width": 576,
        "height": 850,
        "content": "## AI Document Assistant: Branded PDF Generation from Email\n\nReceive an email with a document request and optional PDF attachments. The AI assistant can create drafts, summarize documents, compare mul"
      }
    },
    {
      "id": "6cb7e941-ffac-469b-b3bb-5c5548558606",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -16784,
        2864
      ],
      "parameters": {
        "width": 700,
        "height": 260,
        "content": "### 1. Email Input & Config\nThe IMAP Email Trigger monitors your inbox for incoming document requests. PDF attachments are automatically detected. The Set Company Config node defines branding variable"
      }
    },
    {
      "id": "67d4eed1-67c4-40e0-a1c8-4f402327db8b",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -15856,
        3104
      ],
      "parameters": {
        "width": 1512,
        "height": 452,
        "content": "### 2. PDF Processing Loop\nEach uploaded PDF is processed sequentially: uploaded to Autype via the community node, OCR'd via Autype Lens (HTTP Request), then the extracted markdown text is collected. "
      }
    },
    {
      "id": "303e476e-c3ba-4ce7-987c-41bd83bf458e",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -15616,
        2640
      ],
      "parameters": {
        "width": 780,
        "height": 292,
        "content": "### 3. AI Document Assistant\nThe AI Assistant receives the request text, all OCR content from attached PDFs, and the Autype Extended Markdown syntax reference. It can summarize, compare, draft, or cre"
      }
    },
    {
      "id": "50b38871-3e87-4bfa-8a42-11e74a12005d",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -14560,
        2576
      ],
      "parameters": {
        "width": 668,
        "height": 308,
        "content": "### 4. Render & Send\nThe AI output is cleaned and rendered to a branded PDF via Autype Render from Markdown. Company styling is applied via a defaults JSON (fonts, colors, heading styles, table styles"
      }
    },
    {
      "id": "b5611b64-205a-4d01-b262-55cae1cd2af2",
      "name": "Set Company Config",
      "type": "n8n-nodes-base.set",
      "position": [
        -16496,
        2960
      ]
    },
    {
      "id": "13711b2a-2a55-4500-9390-9293a87af7d8",
      "name": "New Email Received",
      "type": "n8n-nodes-base.emailReadImap",
      "position": [
        -16736,
        2960
      ]
    },
    {
      "id": "9b84550e-70e7-4e43-91bb-70b1ba30a189",
      "name": "Extract & Split PDFs",
      "type": "n8n-nodes-base.code",
      "position": [
        -16288,
        2960
      ]
    },
    {
      "id": "214e9426-fff8-4a82-a015-233306d184c0",
      "name": "Has PDFs?",
      "type": "n8n-nodes-base.if",
      "position": [
        -16064,
        2960
      ]
    },
    {
      "id": "27c24be6-1e45-46bc-bff3-b1228998b736",
      "name": "Loop Over PDFs",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        -15792,
        3360
      ]
    },
    {
      "id": "30a46778-ed0f-4ad6-86c9-e2c6b7d9b50d",
      "name": "Upload PDF to Autype",
      "type": "n8n-nodes-autype.autype",
      "position": [
        -15440,
        3312
      ]
    },
    {
      "id": "360692db-d3be-42c4-8ae5-cb7149701ae3",
      "name": "Wait for OCR",
      "type": "n8n-nodes-base.wait",
      "position": [
        -14992,
        3312
      ]
    },
    {
      "id": "23289509-ed73-48a7-bae8-35de4ca79d6e",
      "name": "Poll OCR Status",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -14768,
        3312
      ]
    },
    {
      "id": "22ed08f4-1d00-417f-aca4-9a7b1be666dc",
      "name": "Extract OCR Text",
      "type": "n8n-nodes-base.code",
      "position": [
        -14544,
        3312
      ]
    },
    {
      "id": "44aab7d9-445a-4978-8622-a190828fc3a4",
      "name": "Combine All OCR Results",
      "type": "n8n-nodes-base.code",
      "position": [
        -15600,
        3200
      ]
    },
    {
      "id": "53d42f3e-7327-4cd6-9f6d-3a6b296434fc",
      "name": "Prepare Text Only",
      "type": "n8n-nodes-base.code",
      "position": [
        -15776,
        2768
      ]
    },
    {
      "id": "d16c4859-0eeb-4951-af07-a94dbb80ffb4",
      "name": "Download Markdown Syntax",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -15504,
        2768
      ]
    },
    {
      "id": "9f865bee-62a8-407b-869b-29ad03844a17",
      "name": "Merge Context",
      "type": "n8n-nodes-base.code",
      "position": [
        -15312,
        2768
      ]
    },
    {
      "id": "fb2f1810-2947-4d44-94b8-c10c87013228",
      "name": "AI Document Assistant",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -15088,
        2768
      ]
    },
    {
      "id": "70d3be18-47e7-4640-a5f0-473d9e5553db",
      "name": "Prepare Render Payload",
      "type": "n8n-nodes-base.code",
      "position": [
        -14496,
        2704
      ]
    },
    {
      "id": "bea023a8-09d9-476e-896f-b937531efd8d",
      "name": "Render Branded PDF",
      "type": "n8n-nodes-autype.autype",
      "position": [
        -14304,
        2704
      ]
    },
    {
      "id": "69c3f622-ab0c-4a55-bd62-d352782b6d68",
      "name": "Send Report via Email",
      "type": "n8n-nodes-base.emailSend",
      "position": [
        -14112,
        2704
      ]
    },
    {
      "id": "a20a6e19-7a60-4091-bd25-c939ad1f4505",
      "name": "/scrape in Firecrawl",
      "type": "@mendable/n8n-nodes-firecrawl.firecrawlTool",
      "position": [
        -14800,
        2960
      ]
    },
    {
      "id": "80f59ecf-1be3-4f3a-aa7c-587ff41410fe",
      "name": "OpenRouter Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
      "position": [
        -15184,
        2944
      ]
    },
    {
      "id": "6f69382b-4322-4138-aa98-6c521738cda4",
      "name": "SerpAPI",
      "type": "@n8n/n8n-nodes-langchain.toolSerpApi",
      "position": [
        -14944,
        2960
      ]
    },
    {
      "id": "ff290efa-8e2d-4ce3-8f60-0c24587176df",
      "name": "Autype Lens OCR",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -15216,
        3312
      ]
    }
  ],
  "connections": {
    "SerpAPI": {
      "ai_tool": [
        [
          {
            "node": "AI Document Assistant",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Has PDFs?": {
      "main": [
        [
          {
            "node": "Loop Over PDFs",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Prepare Text Only",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait for OCR": {
      "main": [
        [
          {
            "node": "Poll OCR Status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge Context": {
      "main": [
        [
          {
            "node": "AI Document Assistant",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over PDFs": {
      "main": [
        [
          {
            "node": "Combine All OCR Results",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Upload PDF to Autype",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Autype Lens OCR": {
      "main": [
        [
          {
            "node": "Wait for OCR",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Poll OCR Status": {
      "main": [
        [
          {
            "node": "Extract OCR Text",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract OCR Text": {
      "main": [
        [
          {
            "node": "Loop Over PDFs",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare Text Only": {
      "main": [
        [
          {
            "node": "Download Markdown Syntax",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "New Email Received": {
      "main": [
        [
          {
            "node": "Set Company Config",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Render Branded PDF": {
      "main": [
        [
          {
            "node": "Send Report via Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Company Config": {
      "main": [
        [
          {
            "node": "Extract & Split PDFs",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "/scrape in Firecrawl": {
      "ai_tool": [
        [
          {
            "node": "AI Document Assistant",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Extract & Split PDFs": {
      "main": [
        [
          {
            "node": "Has PDFs?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Upload PDF to Autype": {
      "main": [
        [
          {
            "node": "Autype Lens OCR",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Document Assistant": {
      "main": [
        [
          {
            "node": "Prepare Render Payload",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenRouter Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Document Assistant",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Prepare Render Payload": {
      "main": [
        [
          {
            "node": "Render Branded PDF",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Combine All OCR Results": {
      "main": [
        [
          {
            "node": "Download Markdown Syntax",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download Markdown Syntax": {
      "main": [
        [
          {
            "node": "Merge Context",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}