{
  "name": "Extract invoice data from Gmail to Airtable with Mistral OCR and GPT-4.1-mini",
  "nodes": [
    {
      "id": "ebb51c1f-8b91-4165-8a14-ff6be7890cb4",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        240,
        1296
      ]
    },
    {
      "id": "2d47510f-724e-462c-94ff-87e86e6daaa4",
      "name": "Structured Output Parser",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        -32,
        1280
      ]
    },
    {
      "id": "0a369168-d88e-4097-978e-e25005b0eced",
      "name": "Gmail Trigger",
      "type": "n8n-nodes-base.gmailTrigger",
      "position": [
        -1328,
        1184
      ]
    },
    {
      "id": "717865e0-8312-4fe5-8eb8-6cc1f371e28e",
      "name": "If",
      "type": "n8n-nodes-base.if",
      "position": [
        -1168,
        1184
      ]
    },
    {
      "id": "60336b22-1df3-4307-a588-a6dc0f7e9682",
      "name": "No Operation, do nothing",
      "type": "n8n-nodes-base.noOp",
      "position": [
        -880,
        1328
      ]
    },
    {
      "id": "b2d37a06-ae4e-4abc-a403-c479cd06e962",
      "name": "host image",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -928,
        1056
      ]
    },
    {
      "id": "89604f3d-e966-4318-ac4e-29ba608db729",
      "name": "Extract text",
      "type": "n8n-nodes-base.mistralAi",
      "position": [
        -160,
        976
      ]
    },
    {
      "id": "797fa0a5-dbd3-4d7e-ab8b-c97932422309",
      "name": "Download Invoice",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -320,
        976
      ]
    },
    {
      "id": "8c9c6db3-6f30-458e-936c-e6adcacc6ebf",
      "name": "Analyze Invoices",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        16,
        976
      ]
    },
    {
      "id": "355b5cfc-f6cb-4781-8f4c-0f1c47cb5d18",
      "name": "Search Existing Invoices",
      "type": "n8n-nodes-base.airtable",
      "position": [
        -688,
        1056
      ]
    },
    {
      "id": "1fc26efe-06ae-4cb9-b4ca-153b718c9f12",
      "name": "Check for Duplicates",
      "type": "n8n-nodes-base.switch",
      "position": [
        -512,
        1056
      ]
    },
    {
      "id": "c496f51b-943e-41b9-ba27-7a96aa22e695",
      "name": "Validate Data",
      "type": "n8n-nodes-base.if",
      "position": [
        304,
        976
      ]
    },
    {
      "id": "957fca86-bb26-4682-922b-bd4abcc566dd",
      "name": "Invalid Data Handler",
      "type": "n8n-nodes-base.set",
      "position": [
        560,
        1104
      ]
    },
    {
      "id": "df661869-6506-469b-bb65-4a3adbf379dc",
      "name": "Send Error Email",
      "type": "n8n-nodes-base.gmail",
      "position": [
        784,
        1104
      ]
    },
    {
      "id": "3095cb76-1aca-441a-8157-21a65e785826",
      "name": "No Operation, do nothing1",
      "type": "n8n-nodes-base.noOp",
      "position": [
        -304,
        1280
      ]
    },
    {
      "id": "5653a1bb-cec9-4099-8d7d-8aa15a1cb760",
      "name": "upload invoice & details",
      "type": "n8n-nodes-base.airtable",
      "position": [
        560,
        848
      ]
    },
    {
      "id": "a4da130a-6c16-47e5-8b66-761720921697",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2336,
        688
      ],
      "parameters": {
        "width": 832,
        "height": 1216,
        "content": "# 🛠️ Setup Guide\n\n**Author:** [Safa Khan]()\n\nFollow the steps below to get this workflow up and running:\n\n### ✅ Step 1: Choose Your Trigger\n\nDetermine what will kick off this workflow. In this example"
      }
    },
    {
      "id": "7080e6a2-30ca-41de-90db-729b79e08927",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1424,
        1040
      ],
      "parameters": {
        "width": 224,
        "height": 304,
        "content": "## Trigger"
      }
    },
    {
      "id": "4ef686e8-345e-435a-bff4-5e78dba62bb9",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1200,
        1040
      ],
      "parameters": {
        "width": 176,
        "height": 304,
        "content": "## Filter Logic"
      }
    },
    {
      "id": "27f96b32-fcc6-40a4-997f-e84a0a23864b",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -992,
        944
      ],
      "parameters": {
        "width": 208,
        "height": 288,
        "content": "## Image hosting"
      }
    },
    {
      "id": "4c22a7c8-0d30-4099-9bcf-ca1e43a184f5",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -768,
        944
      ],
      "parameters": {
        "width": 400,
        "height": 288,
        "content": "## Duplicate Protection"
      }
    },
    {
      "id": "a4010d10-4e09-48f0-b22e-852ee668b570",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -368,
        880
      ],
      "parameters": {
        "width": 352,
        "height": 256,
        "content": "## OCR Extraction"
      }
    },
    {
      "id": "d5eab68a-eb4e-408a-b954-98f018749fc4",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        864
      ],
      "parameters": {
        "width": 272,
        "height": 272,
        "content": "## AI Data Structuring"
      }
    },
    {
      "id": "8ada1b6e-e2a0-4b2c-869a-3194dcdcf955",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        480,
        752
      ],
      "parameters": {
        "width": 256,
        "height": 256,
        "content": "## Store Invoice"
      }
    },
    {
      "id": "b7a2bc04-1fb2-44e9-9ce5-2d8dfead6d33",
      "name": "Sticky Note8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        480,
        1024
      ],
      "parameters": {
        "width": 480,
        "height": 224,
        "content": "## Error Handling"
      }
    }
  ],
  "connections": {
    "If": {
      "main": [
        [
          {
            "node": "host image",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "No Operation, do nothing",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "host image": {
      "main": [
        [
          {
            "node": "Search Existing Invoices",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract text": {
      "main": [
        [
          {
            "node": "Analyze Invoices",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gmail Trigger": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Validate Data": {
      "main": [
        [
          {
            "node": "upload invoice & details",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Invalid Data Handler",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Analyze Invoices": {
      "main": [
        [
          {
            "node": "Validate Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download Invoice": {
      "main": [
        [
          {
            "node": "Extract text",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Analyze Invoices",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Check for Duplicates": {
      "main": [
        [
          {
            "node": "Download Invoice",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "No Operation, do nothing1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Invalid Data Handler": {
      "main": [
        [
          {
            "node": "Send Error Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Search Existing Invoices": {
      "main": [
        [
          {
            "node": "Check for Duplicates",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "Analyze Invoices",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    }
  }
}