{
  "name": "GPT-4.1-mini Powered Invoice Processing from Gmail to Google Sheets with Slack",
  "nodes": [
    {
      "id": "6a927310-5fc7-43bd-87af-424bd7c55cb0",
      "name": "1. New Invoice Email Received",
      "type": "n8n-nodes-base.gmailTrigger",
      "position": [
        -848,
        -528
      ]
    },
    {
      "id": "f8ccf24e-2bd0-45d7-8913-390017b8bb86",
      "name": "2. Get Email Attachments",
      "type": "n8n-nodes-base.gmail",
      "position": [
        -624,
        -528
      ]
    },
    {
      "id": "9735648c-b000-4609-ba2a-f3abf3f9ecf4",
      "name": "3. Extract Text from PDF",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        -400,
        -528
      ]
    },
    {
      "id": "35f7be1c-4edf-439a-8fcb-0bca17c9572f",
      "name": "4. Prepare Text for AI",
      "type": "n8n-nodes-base.set",
      "position": [
        -176,
        -528
      ]
    },
    {
      "id": "d2e5f759-f7f1-4f1e-bdce-9953e010067a",
      "name": "5. Extract Invoice Data with AI",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        48,
        -528
      ]
    },
    {
      "id": "1997c1a1-6d0b-4978-b016-e165bff3b9fe",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        64,
        -304
      ]
    },
    {
      "id": "a0873ce5-7bc6-432c-9782-7f0f38cbbe36",
      "name": "Webhook (Approve)",
      "type": "n8n-nodes-base.webhook",
      "position": [
        -864,
        -16
      ]
    },
    {
      "id": "3c059939-48aa-4f1e-9885-ba4090a53c07",
      "name": "Webhook (Reject)",
      "type": "n8n-nodes-base.webhook",
      "position": [
        -864,
        208
      ]
    },
    {
      "id": "084e5e25-96e7-481a-8bfc-41ebb99d1ca1",
      "name": "10a. Send Approval Confirmation",
      "type": "n8n-nodes-base.slack",
      "position": [
        -192,
        -16
      ]
    },
    {
      "id": "3168c089-d89a-4649-b0d6-498417207953",
      "name": "10b. Send Rejection Confirmation",
      "type": "n8n-nodes-base.slack",
      "position": [
        -192,
        208
      ]
    },
    {
      "id": "61afe930-9395-4ca5-aebd-c610edc207eb",
      "name": "6. Log Invoice to Google Sheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        400,
        -528
      ]
    },
    {
      "id": "67931763-dd8b-42e3-a2a5-c8bdf82e7e6f",
      "name": "Structured Output Parser",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        192,
        -304
      ]
    },
    {
      "id": "1f145d04-12e7-4345-b67e-8621bf192800",
      "name": "9a. Update Status to Approved",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -416,
        -16
      ]
    },
    {
      "id": "e9128567-5ea7-49b5-9ace-280e49026787",
      "name": "9b. Update Status to Rejected",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -416,
        208
      ]
    },
    {
      "id": "bfc86cd9-f0d2-4c01-8cca-24388245c93e",
      "name": "7. Send Approval Request to Slack",
      "type": "n8n-nodes-base.slack",
      "position": [
        624,
        -528
      ]
    },
    {
      "id": "20ac3190-2d82-43e9-b47b-69133ceb3af6",
      "name": "8a. Extract Invoice ID",
      "type": "n8n-nodes-base.set",
      "position": [
        -640,
        -16
      ]
    },
    {
      "id": "2d72c14f-cd66-4d2e-84a7-23c522787d57",
      "name": "8b. Extract Invoice ID",
      "type": "n8n-nodes-base.set",
      "position": [
        -640,
        208
      ]
    },
    {
      "id": "848586fb-b5c1-4595-abba-31de9a0f0497",
      "name": "GPT-4.1-mini Powered Invoice Processing",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1696,
        -1632
      ],
      "parameters": {
        "width": 944,
        "height": 816,
        "content": "This workflow automates your invoice processing pipeline. It triggers on a new Gmail invoice, uses AI to extract data, logs it to a Google Sheet, and sends a Slack message with approval/rejection link"
      }
    },
    {
      "id": "32b5eb12-99c5-4a84-a0fb-5864d8e89e44",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1152,
        -784
      ],
      "parameters": {
        "width": 480,
        "height": 240,
        "content": "## Trigger\nThis node starts the workflow when an email matching the filter arrives.\n\n**Setup:** \n1. Add Gmail credentials.\n2. Change the search query `q` to your invoice keyword (e.g., \"invoice\")."
      }
    },
    {
      "id": "b7352552-cca3-4f9c-99ef-d9441874d56f",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -592,
        -768
      ],
      "parameters": {
        "width": 400,
        "height": 192,
        "content": "## Data Preparation\nThese nodes download the PDF from the email and extract its raw text content, preparing it for the AI."
      }
    },
    {
      "id": "ca5ed7e7-6d1c-4990-aa8f-0e30743ae11e",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -16,
        -784
      ],
      "parameters": {
        "width": 384,
        "height": 224,
        "content": "## AI Extraction & Logging\nAn AI model extracts structured data from the text, which is then appended to your Google Sheet.\n\n**Setup:**\n1. Add OpenAI & Google Sheets credentials.\n2. Enter your Sheet I"
      }
    },
    {
      "id": "d1fd4b75-a743-4b6f-a361-468fce76e6c6",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        544,
        -800
      ],
      "parameters": {
        "width": 368,
        "height": 240,
        "content": "## Slack Approval Request\nSends a message to Slack containing the invoice details and unique approval/rejection links.\n\n**Setup:**\n1. Add Slack credentials.\n2. Enter your Slack Channel ID.\n3. **IMPORT"
      }
    },
    {
      "id": "24adce38-a0b9-4b2f-8c38-d90e1cbca515",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -864,
        -176
      ],
      "parameters": {
        "width": 640,
        "height": 112,
        "content": "## Approval/Rejection Handling\nThese nodes listen for clicks on the Slack links. They update the Google Sheet status to \"approved\" or \"rejected\" and send a final confirmation message back to Slack."
      }
    }
  ],
  "connections": {
    "Webhook (Reject)": {
      "main": [
        [
          {
            "node": "8b. Extract Invoice ID",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "5. Extract Invoice Data with AI",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Webhook (Approve)": {
      "main": [
        [
          {
            "node": "8a. Extract Invoice ID",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "4. Prepare Text for AI": {
      "main": [
        [
          {
            "node": "5. Extract Invoice Data with AI",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "8a. Extract Invoice ID": {
      "main": [
        [
          {
            "node": "9a. Update Status to Approved",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "8b. Extract Invoice ID": {
      "main": [
        [
          {
            "node": "9b. Update Status to Rejected",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "2. Get Email Attachments": {
      "main": [
        [
          {
            "node": "3. Extract Text from PDF",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "3. Extract Text from PDF": {
      "main": [
        [
          {
            "node": "4. Prepare Text for AI",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "5. Extract Invoice Data with AI",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "1. New Invoice Email Received": {
      "main": [
        [
          {
            "node": "2. Get Email Attachments",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "9a. Update Status to Approved": {
      "main": [
        [
          {
            "node": "10a. Send Approval Confirmation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "9b. Update Status to Rejected": {
      "main": [
        [
          {
            "node": "10b. Send Rejection Confirmation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "6. Log Invoice to Google Sheet": {
      "main": [
        [
          {
            "node": "7. Send Approval Request to Slack",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "5. Extract Invoice Data with AI": {
      "main": [
        [
          {
            "node": "6. Log Invoice to Google Sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}