AutomationFlowsAI & RAG › Extract Invoice Data From Gmail with Gpt-4o and Send Slack Notifications

Extract Invoice Data From Gmail with Gpt-4o and Send Slack Notifications

ByMatt Chong | n8n Creator @mattxchong on n8n.io

This workflow is ideal for freelancers, accountants, and finance teams who receive invoices in Gmail and want to automate their tracking process with AI.

Cron / scheduled trigger★★★★☆ complexityAI-powered12 nodesAgentOpenAI ChatOutput Parser StructuredGmailSlack
AI & RAG Trigger: Cron / scheduled Nodes: 12 Complexity: ★★★★☆ AI nodes: yes Added:

This workflow corresponds to n8n.io template #7735 — we link there as the canonical source.

This workflow follows the Agent → Gmail recipe pattern — see all workflows that pair these two integrations.

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "name": "AI Auto-Detect Invoices from Gmail and Notify on Slack",
  "nodes": [
    {
      "id": "df47f544-18a9-4eea-a02f-6e8618bdc903",
      "name": "Schedule Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -1488,
        -16
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "hours"
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "fb69e703-7747-4862-8208-0d0803f5ce8f",
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "onError": "continueRegularOutput",
      "position": [
        -1040,
        -16
      ],
      "parameters": {
        "text": "=You are an intelligent assistant that reads emails and determines whether the message is related to an invoice or a payment notification.\n\nYour tasks:\n1. Determine if the email is invoice-related.\n2. If yes, extract:\n   - Due date (in YYYY-MM-DD format, or null)\n   - Amount due (as a number, no currency symbols)\n\nAlways include these metadata values:\nId: {{ $json.id }}\nthreadId: {{ $json.threadId }}\nbody: {{ $json.text }}\nsubject: {{ $json.subject }}\nsender: {{ $json.from.value[0].name }}\n\nReturn only a valid JSON object in the format below:\n\n```json\n{\n  \"is_invoice\": true or false,\n  \"due_date\": \"YYYY-MM-DD\" or null,\n  \"amount_due\": number or null,\n  \"email_id\": \"string\",\n  \"thread_id\": \"string\",\n  \"sender\": \"string\",\n  \"subject\": \"string\"\n}\n\n\n",
        "options": {},
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 2.1
    },
    {
      "id": "ff1adb6a-43d6-4b36-9c91-0046b0146565",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -1024,
        208
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o",
          "cachedResultName": "gpt-4o"
        },
        "options": {}
      },
      "typeVersion": 1.2
    },
    {
      "id": "acc58349-b51f-4623-9a23-f740791483fb",
      "name": "Structured Output Parser",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        -896,
        208
      ],
      "parameters": {
        "schemaType": "manual",
        "inputSchema": "{\n  \"type\": \"object\",\n  \"properties\": {\n    \"is_invoice\": {\n      \"type\": \"boolean\"\n    },\n    \"due_date\": {\n      \"type\": [\"string\", \"null\"],\n      \"format\": \"date\"\n    },\n    \"amount_due\": {\n      \"type\": [\"number\", \"null\"]\n    },\n    \"email_id\": {\n      \"type\": \"string\"\n    },\n    \"thread_id\": {\n      \"type\": \"string\"\n    },\n    \"sender\": {\n      \"type\": \"string\"\n    },\n    \"subject\": {\n      \"type\": \"string\"\n    }\n  },\n  \"required\": [\n    \"is_invoice\",\n    \"due_date\",\n    \"amount_due\",\n    \"email_id\",\n    \"thread_id\",\n    \"sender\",\n    \"subject\"\n  ]\n}"
      },
      "typeVersion": 1.3
    },
    {
      "id": "436dccba-2b62-4ee9-b2c3-0581bc836ed7",
      "name": "No Operation, do nothing",
      "type": "n8n-nodes-base.noOp",
      "position": [
        -464,
        80
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "4c1eb726-1666-4f5c-b4e0-8f938f3ef791",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1552,
        208
      ],
      "parameters": {
        "width": 304,
        "height": 224,
        "content": "### \u26a0\ufe0f Setup Required  \n- Connect your Gmail account using OAuth2  \n- Connect your Slack account using OAuth 2\n- Add your OpenAI API Key under **API Credentials**  "
      },
      "typeVersion": 1
    },
    {
      "id": "17c6acfe-6074-43f9-af78-8a2f7104df5b",
      "name": "Get Unread Emails",
      "type": "n8n-nodes-base.gmail",
      "position": [
        -1264,
        -16
      ],
      "parameters": {
        "simple": false,
        "filters": {
          "readStatus": "unread"
        },
        "options": {},
        "operation": "getAll"
      },
      "typeVersion": 2.1
    },
    {
      "id": "51725993-99b5-4d9e-a562-4e762ca6a0a2",
      "name": "Check If Email is Invoice",
      "type": "n8n-nodes-base.if",
      "position": [
        -688,
        -16
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "dc8158a0-29aa-4c7f-9de3-994a5d827331",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              },
              "leftValue": "={{ $json.output.is_invoice }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "ec14d8de-cfab-4b53-a3b5-9aae1c3b808d",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1600,
        -128
      ],
      "parameters": {
        "color": 5,
        "width": 320,
        "height": 272,
        "content": "### \ud83d\udca1 Schedule Trigger  \nThis runs every hour.  \nYou can change the interval here depending on how often you want Gmail to be checked."
      },
      "typeVersion": 1
    },
    {
      "id": "3f7e75ec-5a03-4664-b1ff-91f57bee2d9d",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -528,
        -336
      ],
      "parameters": {
        "color": 5,
        "width": 272,
        "height": 400,
        "content": "### \ud83d\udca1 Customize Notification Format  \nYou can change the title in this node.  For example: `Pay invoice from {{sender}} by {{due_date}}`  \nInclude more invoice details in the notes field if needed.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "db70ae0c-794b-452e-b8cd-26574ff006a2",
      "name": "Notify Slack User",
      "type": "n8n-nodes-base.slack",
      "position": [
        -464,
        -112
      ],
      "parameters": {
        "text": "=Invoice from {{ $json.output.sender }} \u2013 ${{ $json.output.amount_due }} due {{ $json.output.due_date }}",
        "user": {
          "__rl": true,
          "mode": "username",
          "value": ""
        },
        "select": "user",
        "otherOptions": {},
        "authentication": "oAuth2"
      },
      "typeVersion": 2.3
    },
    {
      "id": "d9bc11f7-edb5-4521-9702-725c8fa736fc",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1120,
        -256
      ],
      "parameters": {
        "color": 5,
        "width": 400,
        "height": 640,
        "content": "### \ud83e\udd16 AI Agent\n\n\u2022 This node uses an AI prompt to detect whether an email is invoice-related.\n\u2022 You can customize the prompt to detect other types of emails (e.g., receipts, contracts).\n"
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "AI Agent": {
      "main": [
        [
          {
            "node": "Check If Email is Invoice",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "Get Unread Emails",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Unread Emails": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "AI Agent",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Check If Email is Invoice": {
      "main": [
        [
          {
            "node": "Notify Slack User",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "No Operation, do nothing",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

This workflow is ideal for freelancers, accountants, and finance teams who receive invoices in Gmail and want to automate their tracking process with AI.

Source: https://n8n.io/workflows/7735/ — original creator credit. Request a take-down →

More AI & RAG workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

AI & RAG

Created by: Peyton Leveillee Last updated: October 2025

OpenAI Chat, Google Sheets, HTTP Request +5
AI & RAG

This n8n-powered workflow automates the entire lifecycle of real estate lead intake, qualification, routing, assignment, and reporting across multiple channels. It brings WhatsApp inquiries and websit

Gmail, Typeform Trigger, WhatsApp Trigger +8
AI & RAG

This workflow automates end-to-end sustainability lifecycle management for corporate sustainability teams, ESG governance officers, and circular economy programme leads. It addresses the challenge of

Form Trigger, Agent, OpenAI Chat +11
AI & RAG

This workflow automates end-to-end ESG (Environmental, Social, and Governance) sustainability reporting for enterprise sustainability teams, compliance officers, and green governance leads. It solves

Agent, OpenAI Chat, Output Parser Structured +12
AI & RAG

This template is designed for B2B sales teams, recruiters, and business development professionals who want to identify sales opportunities by monitoring hiring signals from target companies. It's part

@Apify/N8N Nodes Apify, Google Sheets, Agent +4