{
  "name": "Automate invoice processing from Gmail with Azure GPT-4.1 and human verification",
  "nodes": [
    {
      "id": "a6fd1034-16ac-48ce-a20e-5d00f9709d76",
      "name": "Gmail Trigger",
      "type": "n8n-nodes-base.gmailTrigger",
      "position": [
        40,
        220
      ]
    },
    {
      "id": "b4829627-2c3e-477c-8ff0-9754f0010826",
      "name": "IF: AI Says Yes",
      "type": "n8n-nodes-base.if",
      "position": [
        1020,
        260
      ]
    },
    {
      "id": "14933a59-1cd2-4572-aa92-8968ffa03b8a",
      "name": "Save PDF Locally",
      "type": "n8n-nodes-base.writeBinaryFile",
      "position": [
        1640,
        220
      ]
    },
    {
      "id": "0a17eed9-be81-4576-b218-ad12b3ffac28",
      "name": "Merge",
      "type": "n8n-nodes-base.merge",
      "position": [
        1480,
        220
      ]
    },
    {
      "id": "e577ce73-0505-45f0-80cb-aa6d241f1add",
      "name": "Information Extractor",
      "type": "@n8n/n8n-nodes-langchain.informationExtractor",
      "position": [
        660,
        280
      ]
    },
    {
      "id": "861f5008-bd46-4091-b040-b7b2fe1e6f45",
      "name": "Is this PDF?",
      "type": "n8n-nodes-base.if",
      "position": [
        260,
        220
      ]
    },
    {
      "id": "e23bf999-1718-4489-a308-e244b22e14ad",
      "name": "Send a message",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1020,
        480
      ]
    },
    {
      "id": "bc2a8732-2e5f-421b-8df1-37a6ec2f7a2e",
      "name": "Invoice Saved Message",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1800,
        220
      ]
    },
    {
      "id": "c9155103-6c04-438a-8e90-edb63b9ffd1a",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        120
      ],
      "parameters": {
        "width": 200,
        "height": 300,
        "content": "Triggers Gmail when new email from specific email account is received.\n"
      }
    },
    {
      "id": "a7a4385d-f00e-493c-9757-fbd660a64354",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        220,
        120
      ],
      "parameters": {
        "width": 180,
        "height": 300,
        "content": "Checks if there is any pdf attachments in email, and Invoice is included in subject\n"
      }
    },
    {
      "id": "da0c4d5e-9c24-4f3d-a17a-ca92d3299729",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        420,
        0
      ],
      "parameters": {
        "width": 180,
        "height": 600,
        "content": "If both are true, it extracts the information from the pdf.\n\nIf not, it gives an error saying that there is no invoice file included."
      }
    },
    {
      "id": "2196f52f-9e5b-4acd-b173-86ff7e986b71",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        620,
        0
      ],
      "parameters": {
        "width": 780,
        "height": 660,
        "content": "This checks the extracted information from the pdf and analyze if it is invoice.\n\nBased on the information, if it is invoice, it gives output of \"Yes\", otherwise \"No\".\n\nIf \"Yes\", it merges response to"
      }
    },
    {
      "id": "ba5b7574-a2e1-401e-aab0-c7ca6b7856d8",
      "name": "Azure OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatAzureOpenAi",
      "position": [
        660,
        440
      ]
    },
    {
      "id": "42973f72-4ce9-4fff-90e5-9a09cc68f39b",
      "name": "Manual Verification",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1200,
        340
      ]
    },
    {
      "id": "f1d15106-d677-4484-8602-7091c87be5c7",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1420,
        120
      ],
      "parameters": {
        "width": 560,
        "height": 300,
        "content": "After verifying that the file is an invoice, it saves the file in the local directory. When the workflow is completed, it sends a success email to user."
      }
    },
    {
      "id": "f589f451-3faf-4930-ab12-4796f219d066",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        0
      ],
      "parameters": {
        "width": 400,
        "height": 100,
        "content": "## Use this to automatically save invoice received in an email"
      }
    },
    {
      "id": "3b021445-e52e-4191-a454-654ba26e1bba",
      "name": "Error Handler",
      "type": "n8n-nodes-base.stopAndError",
      "position": [
        460,
        440
      ]
    }
  ],
  "connections": {
    "Merge": {
      "main": [
        [
          {
            "node": "Save PDF Locally",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Is this PDF?": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          },
          {
            "node": "Information Extractor",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Error Handler",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gmail Trigger": {
      "main": [
        [
          {
            "node": "Is this PDF?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "IF: AI Says Yes": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 1
          }
        ],
        [
          {
            "node": "Manual Verification",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Save PDF Locally": {
      "main": [
        [
          {
            "node": "Invoice Saved Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Information Extractor": {
      "main": [
        [
          {
            "node": "IF: AI Says Yes",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Send a message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Azure OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Information Extractor",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    }
  }
}