{
  "name": "Automate invoice processing with Gmail, OCR.space, Slack & Xero",
  "nodes": [
    {
      "id": "189e9199-b377-4acc-a0e7-d5769e69a762",
      "name": "Gmail Trigger",
      "type": "n8n-nodes-base.gmailTrigger",
      "position": [
        -96,
        16
      ]
    },
    {
      "id": "7c5278ea-c32f-4f55-9ba4-4448c06c21f0",
      "name": "Code in JavaScript",
      "type": "n8n-nodes-base.code",
      "position": [
        80,
        16
      ]
    },
    {
      "id": "4ddb1479-1b7f-4f8d-ad41-1a92654c98c8",
      "name": "Append or update row in sheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1296,
        -48
      ]
    },
    {
      "id": "abea5730-c60f-47f4-83b3-50cb42c6c9e0",
      "name": "Slack Approval Request",
      "type": "n8n-nodes-base.slack",
      "position": [
        1904,
        -48
      ]
    },
    {
      "id": "955f6439-8d79-4f9f-b35c-7bf3e39f6aad",
      "name": "Slack Rejection message",
      "type": "n8n-nodes-base.slack",
      "position": [
        1296,
        144
      ]
    },
    {
      "id": "424382f8-ff99-457e-9714-569c83e29157",
      "name": "Check Qualification",
      "type": "n8n-nodes-base.if",
      "position": [
        1040,
        0
      ]
    },
    {
      "id": "be9d4c45-2bb3-4ca4-944e-65045fa75a60",
      "name": "Parse Invoice Data",
      "type": "n8n-nodes-base.code",
      "position": [
        720,
        0
      ]
    },
    {
      "id": "36afc95e-af94-4c98-a458-744e9bfd1139",
      "name": "Format for Slack",
      "type": "n8n-nodes-base.code",
      "position": [
        1504,
        -48
      ]
    },
    {
      "id": "b524a093-e827-4049-b0c9-809dc839465e",
      "name": "Rejection message",
      "type": "n8n-nodes-base.slack",
      "position": [
        2896,
        16
      ]
    },
    {
      "id": "afcf2f08-41ec-4ce5-bb32-98733317379f",
      "name": "Success message",
      "type": "n8n-nodes-base.slack",
      "position": [
        3248,
        -176
      ]
    },
    {
      "id": "2a70f5c0-db5f-44eb-8eb8-24c978892049",
      "name": "Update Rejected Status",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        2704,
        16
      ]
    },
    {
      "id": "f775d6e5-a97b-4aea-be73-f6a3030cbfc3",
      "name": "Update Approved Status",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        3024,
        -176
      ]
    },
    {
      "id": "b062f234-61a1-4913-8135-be9d9be322a8",
      "name": "Add Processed label",
      "type": "n8n-nodes-base.gmail",
      "position": [
        2832,
        -176
      ]
    },
    {
      "id": "854afcd4-6559-4753-b75d-2a65766c492d",
      "name": "Add Rejected label",
      "type": "n8n-nodes-base.gmail",
      "position": [
        2432,
        16
      ]
    },
    {
      "id": "025efb16-32dd-4a7e-8349-baef18b32040",
      "name": "Get many contacts",
      "type": "n8n-nodes-base.xero",
      "position": [
        2416,
        -176
      ]
    },
    {
      "id": "b43a1017-8ecb-4c39-b92f-8865349ccec2",
      "name": "Clean Invoice Payload",
      "type": "n8n-nodes-base.code",
      "position": [
        1696,
        -48
      ]
    },
    {
      "id": "a77a3860-e69a-428f-b74e-d926859c83e3",
      "name": "Create invoice",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2624,
        -176
      ]
    },
    {
      "id": "270ea877-b081-4704-8137-3cbcf62606fb",
      "name": "Has Valid Attachment?",
      "type": "n8n-nodes-base.if",
      "position": [
        288,
        16
      ]
    },
    {
      "id": "4128986d-09d7-44b5-a9f5-5f8a532c1712",
      "name": "Was Approved?",
      "type": "n8n-nodes-base.if",
      "position": [
        2128,
        -48
      ]
    },
    {
      "id": "8400ed04-51ba-4cc6-92cc-abb03a09e258",
      "name": "Extract Text",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        544,
        0
      ]
    },
    {
      "id": "d132fdec-f017-49f6-a4bc-8a938df37d98",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -912,
        -464
      ],
      "parameters": {
        "width": 608,
        "height": 1696,
        "content": "### Automate Invoice Processing with Gmail, OCR.space, Slack & Xero\n\nThis n8n template demonstrates how to automatically extract, validate, approve, and sync invoices received via email using AI and a"
      }
    },
    {
      "id": "b16d6e58-0125-4735-b939-040945fcc89b",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1008,
        -336
      ],
      "parameters": {
        "width": 1248,
        "height": 640,
        "content": "## 2. Approve or Reject Invoice in Slack\n[Read more about Slack Approval workflows in n8n](https://docs.n8n.io/integrations/slack/)\n\nAfter parsing, the workflow evaluates whether the invoice meets pre"
      }
    },
    {
      "id": "af22b982-18c5-4adc-9e88-d7ecf53f357c",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -144,
        -336
      ],
      "parameters": {
        "width": 1120,
        "height": 640,
        "content": "## 1. Extract & Parse Invoice from Gmail\n[Read more about the Gmail and HTTP Request nodes](https://docs.n8n.io/integrations/builtin/email-read-imap/)\n  \nThis section listens for new emails via Gmail,"
      }
    },
    {
      "id": "422c5b66-d77a-4224-b689-e4b57152373e",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2288,
        -336
      ],
      "parameters": {
        "width": 1168,
        "height": 640,
        "content": "## 3. Sync Outcome to Xero & Notify\n[Read more about Xero and Gmail automation](https://docs.n8n.io/integrations/xero/)\n\nIf the invoice is approved, the workflow fetches the contact from Xero, creates"
      }
    }
  ],
  "connections": {
    "Extract Text": {
      "main": [
        [
          {
            "node": "Parse Invoice Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gmail Trigger": {
      "main": [
        [
          {
            "node": "Code in JavaScript",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Was Approved?": {
      "main": [
        [
          {
            "node": "Get many contacts",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Add Rejected label",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create invoice": {
      "main": [
        [
          {
            "node": "Add Processed label",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format for Slack": {
      "main": [
        [
          {
            "node": "Clean Invoice Payload",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get many contacts": {
      "main": [
        [
          {
            "node": "Create invoice",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Add Rejected label": {
      "main": [
        [
          {
            "node": "Update Rejected Status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code in JavaScript": {
      "main": [
        [
          {
            "node": "Has Valid Attachment?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse Invoice Data": {
      "main": [
        [
          {
            "node": "Check Qualification",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Add Processed label": {
      "main": [
        [
          {
            "node": "Update Approved Status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Qualification": {
      "main": [
        [
          {
            "node": "Append or update row in sheet",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Slack Rejection message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Clean Invoice Payload": {
      "main": [
        [
          {
            "node": "Slack Approval Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Has Valid Attachment?": {
      "main": [
        [
          {
            "node": "Extract Text",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Slack Approval Request": {
      "main": [
        [
          {
            "node": "Was Approved?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update Approved Status": {
      "main": [
        [
          {
            "node": "Success message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update Rejected Status": {
      "main": [
        [
          {
            "node": "Rejection message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Append or update row in sheet": {
      "main": [
        [
          {
            "node": "Format for Slack",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}