{
  "name": "Xero Bills processing - Gmail Version",
  "nodes": [
    {
      "parameters": {
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        },
        "simple": false,
        "filters": {},
        "options": {
          "downloadAttachments": true
        }
      },
      "type": "n8n-nodes-base.gmailTrigger",
      "typeVersion": 1.2,
      "position": [
        -2800,
        1255
      ],
      "id": "8a3fe0b6-289c-4b60-a5a1-ed0f5136ab86",
      "name": "Gmail Trigger",
      "credentials": {
        "gmailOAuth2": {
          "id": "EcuFmpvd8K7s5KxV",
          "name": "Gmail account"
        }
      }
    },
    {
      "parameters": {
        "operation": "get",
        "messageId": "={{ $('Gmail Trigger').item.json.id }}",
        "simple": false,
        "options": {
          "downloadAttachments": true
        }
      },
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.1,
      "position": [
        -2360,
        1255
      ],
      "id": "f0806b9a-9813-4171-b096-59e18ea966ad",
      "name": "Gmail",
      "webhookId": "b7f54ce6-0bb8-45d3-970c-76fda0729899",
      "credentials": {
        "gmailOAuth2": {
          "id": "EcuFmpvd8K7s5KxV",
          "name": "Gmail account"
        }
      }
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "5638d863-0e83-4214-9c7c-3027a05f8ac7",
              "name": "attachments_metadata",
              "value": "={{ $('Gmail').item.binary.values() }}",
              "type": "array"
            },
            {
              "id": "a465a1ea-9c6d-431a-ad3f-c272ee79a5be",
              "name": "message_id",
              "value": "={{ $('Gmail').item.json.id }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -2140,
        1405
      ],
      "id": "c2f006fb-8f0f-4680-a921-94915d3b916f",
      "name": "Edit Fields"
    },
    {
      "parameters": {
        "fieldToSplitOut": "attachments_metadata",
        "include": "allOtherFields",
        "options": {
          "includeBinary": true
        }
      },
      "type": "n8n-nodes-base.splitOut",
      "typeVersion": 1,
      "position": [
        -1920,
        1405
      ],
      "id": "9216fb6c-7254-4329-bb08-0687e3b15400",
      "name": "Split Out"
    },
    {
      "parameters": {
        "mode": "combine",
        "advanced": true,
        "mergeByFields": {
          "values": [
            {
              "field1": "message_id",
              "field2": "id"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.merge",
      "typeVersion": 3.1,
      "position": [
        -1260,
        1180
      ],
      "id": "b92d7aab-d56c-40c6-a57b-a542c3502264",
      "name": "Merge"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "a9ea58b8-305b-4a36-9ae4-67144354a177",
              "leftValue": "={{ $('Gmail Trigger').item.binary }}",
              "rightValue": "",
              "operator": {
                "type": "object",
                "operation": "exists",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.filter",
      "typeVersion": 2.2,
      "position": [
        -2580,
        1255
      ],
      "id": "c688583d-995f-4678-b858-12f731e14e4f",
      "name": "Filter"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "5638d863-0e83-4214-9c7c-3027a05f8ac7",
              "name": "attachments",
              "value": "={{ $('Gmail').item.binary.keys() }}",
              "type": "array"
            },
            {
              "id": "a465a1ea-9c6d-431a-ad3f-c272ee79a5be",
              "name": "message_id",
              "value": "={{ $('Gmail').item.json.id }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -2140,
        1105
      ],
      "id": "7ee8ad47-6f20-47ad-b375-07fc388da302",
      "name": "Edit Fields2"
    },
    {
      "parameters": {
        "fieldToSplitOut": "attachments",
        "include": "allOtherFields",
        "options": {
          "includeBinary": true
        }
      },
      "type": "n8n-nodes-base.splitOut",
      "typeVersion": 1,
      "position": [
        -1920,
        1105
      ],
      "id": "73afb01d-59da-4ff2-842a-e79db48ed6c6",
      "name": "Split Out1"
    },
    {
      "parameters": {
        "mode": "combine",
        "combineBy": "combineByPosition",
        "options": {}
      },
      "type": "n8n-nodes-base.merge",
      "typeVersion": 3.1,
      "position": [
        -1700,
        1105
      ],
      "id": "e274e0cd-f747-49c8-9413-03a6c85373cf",
      "name": "Merge1"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "a87b73db-6cd9-4b37-bb89-11e265ba61af",
              "leftValue": "={{ $json.attachments_metadata.fileType }}",
              "rightValue": "pdf",
              "operator": {
                "type": "string",
                "operation": "equals",
                "name": "filter.operator.equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.filter",
      "typeVersion": 2.2,
      "position": [
        -1480,
        1105
      ],
      "id": "cac0dcb9-bb56-4cb6-9273-d14da730adbf",
      "name": "Filter1"
    },
    {
      "parameters": {
        "operation": "pdf",
        "binaryPropertyName": "={{ $json.attachments }}",
        "options": {}
      },
      "type": "n8n-nodes-base.extractFromFile",
      "typeVersion": 1,
      "position": [
        -1040,
        1180
      ],
      "id": "a6950b71-5a0f-4a73-9b46-405dd2030709",
      "name": "Extract from File1"
    },
    {
      "parameters": {
        "text": "={{ $('Extract from File1').item.json.text }}",
        "attributes": {
          "attributes": [
            {
              "name": "reference",
              "description": "Invoice  Reference"
            },
            {
              "name": "invoice_issueing_company",
              "description": "Company who is seeking payment\n\nThis will never be \"HybrIT Services NZ\" or \"HybrIT Services NZ Ltd\" as that is the receiving company.",
              "required": true
            },
            {
              "name": "tax",
              "type": "number",
              "description": "Amount of tax included in invoice",
              "required": true
            },
            {
              "name": "total",
              "type": "number",
              "description": "total amount paid or due",
              "required": true
            },
            {
              "name": "issue_date",
              "type": "date",
              "description": "date invoice was issued"
            },
            {
              "name": "due_date",
              "type": "date",
              "description": "date payment is due.\n\nIf not found default to 20th of the month",
              "required": true
            },
            {
              "name": "invoice_number",
              "description": "Invoice Number",
              "required": true
            },
            {
              "name": "issued_to",
              "description": "Company the invoice is issued to (Usually HybrIT Services NZ)"
            },
            {
              "name": "currency",
              "description": "3 letter currency code, e.g. NZD, GBP",
              "required": true
            },
            {
              "name": "tax_rating",
              "description": "=This will be either NONE (no tax) or INPUT2 (15% GST)",
              "required": true
            },
            {
              "name": "summary",
              "description": "1 line summary of all invoice contents. e.g. \"M365 Licenses\"",
              "required": true
            },
            {
              "name": "account_code",
              "type": "number",
              "description": "=Do not invent a new account code - Only use a code from the Chart of Accounts\n\nChart of Accounts:\n\n{{ \n  $('Xero - Get Chart of Accounts1').item.json.Accounts\n    .filter(account => account && account.Code && Number(account.Code) >= 300 && Number(account.Code) <= 495)\n    .map(account => `${account.Code} - ${account.Name} - ${account.Description || \"\"}`)\n    .join('\\n')\n}}\n\n---\nDo not use a code that is not in the above list.\n\n",
              "required": true
            },
            {
              "name": "sub_total",
              "type": "number",
              "description": "Pre Tax Subtotal",
              "required": true
            }
          ]
        },
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.informationExtractor",
      "typeVersion": 1,
      "position": [
        0,
        1180
      ],
      "id": "42d27c6d-8168-4814-8bbb-e638bf4d720c",
      "name": "Information Extractor1"
    },
    {
      "parameters": {
        "modelId": {
          "__rl": true,
          "value": "gpt-4o-mini",
          "mode": "list",
          "cachedResultName": "GPT-4O-MINI"
        },
        "messages": {
          "values": [
            {
              "content": "={{ $json.text }}"
            },
            {
              "content": "=You are an sorting assistant. Your job is to label documents as Invoices or Not invoices by applying a label true or false.\n\nThe label should be applied to a key called isInvoice\n\ne.g.\n\n{\n  \"isInvoice\": true\n}",
              "role": "system"
            }
          ]
        },
        "jsonOutput": true,
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 1.8,
      "position": [
        -820,
        1180
      ],
      "id": "c84b3974-ab91-49d0-9970-5f777557ecf3",
      "name": "OpenAI1",
      "credentials": {
        "openAiApi": {
          "id": "0cs0RBSsQ3W1eoL7",
          "name": "OpenAi account"
        }
      }
    },
    {
      "parameters": {
        "resource": "contact",
        "operation": "getAll",
        "organizationId": "00000000-0000-0000-0000-000000000000",
        "options": {
          "where": "=EmailAddress!=null&&EmailAddress==\"{{ $('Incoming E-mail').item.json.from }}\""
        }
      },
      "type": "n8n-nodes-base.xero",
      "typeVersion": 1,
      "position": [
        592,
        1380
      ],
      "id": "27447ad3-9db8-49eb-b85e-8fc110a02989",
      "name": "Get Account Details1",
      "alwaysOutputData": true,
      "credentials": {
        "xeroOAuth2Api": {
          "id": "tagXpPiiksnqKhbQ",
          "name": "Xero account"
        }
      }
    },
    {
      "parameters": {
        "organizationId": "00000000-0000-0000-0000-000000000000",
        "type": "ACCPAY",
        "contactId": "={{ $json.ContactID }}",
        "lineItemsUi": {
          "lineItemsValues": [
            {
              "description": "={{ $('Information Extractor1').item.json.output.summary }}",
              "unitAmount": "={{ $('Information Extractor1').item.json.output.sub_total }}",
              "itemCode": "={{ null }}",
              "accountCode": "={{ $('Information Extractor1').item.json.output.account_code }}",
              "taxType": "={{ $('Information Extractor1').item.json.output.tax_rating }}",
              "taxAmount": "={{ $('Information Extractor1').item.json.output.tax }}",
              "lineAmount": "={{ $('Information Extractor1').item.json.output.sub_total }}"
            }
          ]
        },
        "additionalFields": {
          "currency": "={{ $('Information Extractor1').item.json.output.currency }}",
          "date": "={{ $('Information Extractor1').item.json.output.issue_date }}",
          "dueDate": "={{ $('Information Extractor1').item.json.output.due_date }}",
          "invoiceNumber": "={{ $('Information Extractor1').item.json.output.invoice_number }}",
          "reference": "={{ $('Information Extractor1').item.json.output.reference }}",
          "status": "DRAFT"
        }
      },
      "type": "n8n-nodes-base.xero",
      "typeVersion": 1,
      "position": [
        1252,
        1180
      ],
      "id": "d8922c97-e190-4403-9dc4-e3258f444eb7",
      "name": "Create Invoice1",
      "credentials": {
        "xeroOAuth2Api": {
          "id": "tagXpPiiksnqKhbQ",
          "name": "Xero account"
        }
      }
    },
    {
      "parameters": {
        "method": "POST",
        "url": "=https://api.xero.com/api.xro/2.0/Invoices/{{ $('Create Invoice1').item.json.InvoiceID }}/Attachments/{{ $('Merge').item.json.attachments_metadata.fileName.replace(/_/g, '-').replace(/[^a-zA-Z0-9.-]/g, '') }}\n",
        "authentication": "genericCredentialType",
        "genericAuthType": "oAuth2Api",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "xero-tenant-id",
              "value": "00000000-0000-0000-0000-000000000000"
            }
          ]
        },
        "sendBody": true,
        "contentType": "binaryData",
        "inputDataFieldName": "={{ $('Merge').item.json.attachments }}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1692,
        1180
      ],
      "id": "3a4e940d-8a52-4740-b77e-86d5a6651329",
      "name": "Xero - Upload Attachment1",
      "credentials": {
        "xeroOAuth2Api": {
          "id": "tagXpPiiksnqKhbQ",
          "name": "Xero account"
        },
        "oAuth2Api": {
          "id": "1z3260nRevdCx2Gi",
          "name": "Xero Custom Auth"
        }
      }
    },
    {
      "parameters": {
        "resource": "contact",
        "organizationId": "00000000-0000-0000-0000-000000000000",
        "name": "={{ $('Information Extractor1').item.json.output.invoice_issueing_company }}",
        "additionalFields": {
          "emailAddress": "={{ $('Incoming E-mail').item.json.from }}"
        }
      },
      "type": "n8n-nodes-base.xero",
      "typeVersion": 1,
      "position": [
        1032,
        1480
      ],
      "id": "6ffba26d-c8be-45b7-9a6f-8dfbfe68269d",
      "name": "Create Contact1",
      "credentials": {
        "xeroOAuth2Api": {
          "id": "tagXpPiiksnqKhbQ",
          "name": "Xero account"
        }
      }
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "value": "gpt-4.1-mini",
          "mode": "list",
          "cachedResultName": "gpt-4.1-mini"
        },
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.2,
      "position": [
        -60,
        1380
      ],
      "id": "046852ba-890e-46c3-9ed3-0566125068b2",
      "name": "OpenAI Chat Model1",
      "credentials": {
        "openAiApi": {
          "id": "0cs0RBSsQ3W1eoL7",
          "name": "OpenAi account"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "b0c37d98-59c3-4958-b575-082e032db89f",
              "leftValue": "={{ $json.message.content.isInvoice }}",
              "rightValue": "true",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        -444,
        1180
      ],
      "id": "1ec623a2-3b54-4936-9e4d-40dd3b04cd93",
      "name": "If Invoice1"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "d4503118-7c01-4e59-b0e8-d9a3e38e4bac",
              "leftValue": "={{ $('Gmail').item.json.from.value[0].address }}",
              "rightValue": "messaging-service@post.xero.com",
              "operator": {
                "type": "string",
                "operation": "equals",
                "name": "filter.operator.equals"
              }
            },
            {
              "id": "92db27a7-194f-44f4-9d6a-d45f2cb39758",
              "leftValue": "={{ $('Gmail').item.json.from.value[0].address }}",
              "rightValue": "you@yourdomain.com",
              "operator": {
                "type": "string",
                "operation": "equals",
                "name": "filter.operator.equals"
              }
            },
            {
              "id": "4671925e-8470-481c-b1e5-9e65050160d8",
              "leftValue": "={{ $('Gmail').item.json.from.value[0].address }}",
              "rightValue": "you@yourdomain.com",
              "operator": {
                "type": "string",
                "operation": "equals",
                "name": "filter.operator.equals"
              }
            },
            {
              "id": "5f65c305-b169-4acd-b673-a94335cfd319",
              "leftValue": "={{ $('Gmail').item.json.from.value[0].address }}",
              "rightValue": "accounts@yourdomain.com",
              "operator": {
                "type": "string",
                "operation": "equals",
                "name": "filter.operator.equals"
              }
            }
          ],
          "combinator": "or"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        372,
        1180
      ],
      "id": "ef27188d-1bc0-4cae-a451-17de19b04960",
      "name": "If Non Specific Email1"
    },
    {
      "parameters": {
        "url": "=https://api.xero.com/api.xro/2.0/Contacts?SearchTerm={{ $('Information Extractor1').item.json.output.invoice_issueing_company }}",
        "authentication": "genericCredentialType",
        "genericAuthType": "oAuth2Api",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "xero-tenant-id",
              "value": "00000000-0000-0000-0000-000000000000"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        592,
        980
      ],
      "id": "edceb66c-c685-4976-9174-c68b4a98b961",
      "name": "Xero - Search Supplier1",
      "credentials": {
        "xeroOAuth2Api": {
          "id": "tagXpPiiksnqKhbQ",
          "name": "Xero account"
        },
        "oAuth2Api": {
          "id": "1z3260nRevdCx2Gi",
          "name": "Xero Custom Auth"
        }
      }
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "3597cbef-f8d4-4f53-8d06-f54347a26fb1",
              "name": "ContactID",
              "value": "={{ $('Get Account Details1').item.json.ContactID }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        1032,
        1280
      ],
      "id": "123ad83f-5aa4-4626-ab2e-089082938f9d",
      "name": "Set ContactID1"
    },
    {
      "parameters": {
        "resource": "contact",
        "organizationId": "00000000-0000-0000-0000-000000000000",
        "name": "={{ $('Information Extractor1').item.json.output.invoice_issueing_company }}",
        "additionalFields": {}
      },
      "type": "n8n-nodes-base.xero",
      "typeVersion": 1,
      "position": [
        1032,
        1080
      ],
      "id": "9fb3e8dd-cd4e-4a9b-adef-42fa5cb52320",
      "name": "Create Contact - No Email1",
      "credentials": {
        "xeroOAuth2Api": {
          "id": "tagXpPiiksnqKhbQ",
          "name": "Xero account"
        }
      }
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "d1d8f409-98ea-41b6-a8ff-7fd82c1fb804",
              "name": "ContactID",
              "value": "={{ $('Xero - Search Supplier1').item.json.Contacts[0].ContactID }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        1032,
        880
      ],
      "id": "2e531d48-6d89-4924-9f47-10eb302b40c4",
      "name": "Set Contact ID1"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "7985a3a7-80be-4256-81a3-1e3b547f23a8",
              "leftValue": "={{ $json.ContactID }}",
              "rightValue": "",
              "operator": {
                "type": "string",
                "operation": "exists",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        812,
        1380
      ],
      "id": "ff93b173-3091-4a4f-a1b8-4a7f7b008ab2",
      "name": "If Contact Exists (Email)1"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "7985a3a7-80be-4256-81a3-1e3b547f23a8",
              "leftValue": "={{ $('Xero - Search Supplier1').item.json.Contacts[0].ContactID }}",
              "rightValue": "",
              "operator": {
                "type": "string",
                "operation": "exists",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        812,
        980
      ],
      "id": "e2011de9-aeb7-4951-bfb6-9f6f100c36e7",
      "name": "If Contact Exists (Name Match)1"
    },
    {
      "parameters": {
        "url": "=https://api.xero.com/api.xro/2.0/Accounts",
        "authentication": "genericCredentialType",
        "genericAuthType": "oAuth2Api",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "xero-tenant-id",
              "value": "00000000-0000-0000-0000-000000000000"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        -224,
        1180
      ],
      "id": "4e012f56-b13d-447b-acd8-f8aa810dd619",
      "name": "Xero - Get Chart of Accounts1",
      "credentials": {
        "xeroOAuth2Api": {
          "id": "tagXpPiiksnqKhbQ",
          "name": "Xero account"
        },
        "oAuth2Api": {
          "id": "1z3260nRevdCx2Gi",
          "name": "Xero Custom Auth"
        }
      }
    },
    {
      "parameters": {
        "operation": "addLabels",
        "messageId": "={{ $('Gmail Trigger').item.json.id }}",
        "labelIds": [
          "Label_6943366242687299423"
        ]
      },
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.1,
      "position": [
        1920,
        1180
      ],
      "id": "314627d5-426b-462b-bd79-44906393a869",
      "name": "Add Label",
      "webhookId": "9ca56bc4-0188-4559-af0b-9587482ed084",
      "credentials": {
        "gmailOAuth2": {
          "id": "EcuFmpvd8K7s5KxV",
          "name": "Gmail account"
        }
      }
    },
    {
      "parameters": {
        "operation": "get",
        "messageId": "={{ $('Gmail Trigger').item.json.id }}",
        "simple": false,
        "options": {
          "downloadAttachments": true
        }
      },
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.1,
      "position": [
        1480,
        1180
      ],
      "id": "fc92c856-d1e7-4b33-a8c6-43a26258eb0f",
      "name": "Download Attachments",
      "webhookId": "b7f54ce6-0bb8-45d3-970c-76fda0729899",
      "credentials": {
        "gmailOAuth2": {
          "id": "EcuFmpvd8K7s5KxV",
          "name": "Gmail account"
        }
      }
    }
  ],
  "pinData": {},
  "connections": {
    "Gmail Trigger": {
      "main": [
        [
          {
            "node": "Filter",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gmail": {
      "main": [
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          },
          {
            "node": "Merge",
            "type": "main",
            "index": 1
          },
          {
            "node": "Edit Fields2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields": {
      "main": [
        [
          {
            "node": "Split Out",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Out": {
      "main": [
        [
          {
            "node": "Merge1",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Merge": {
      "main": [
        [
          {
            "node": "Extract from File1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter": {
      "main": [
        [
          {
            "node": "Gmail",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields2": {
      "main": [
        [
          {
            "node": "Split Out1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Out1": {
      "main": [
        [
          {
            "node": "Merge1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge1": {
      "main": [
        [
          {
            "node": "Filter1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter1": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract from File1": {
      "main": [
        [
          {
            "node": "OpenAI1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Information Extractor1": {
      "main": [
        [
          {
            "node": "If Non Specific Email1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI1": {
      "main": [
        [
          {
            "node": "If Invoice1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Account Details1": {
      "main": [
        [
          {
            "node": "If Contact Exists (Email)1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Invoice1": {
      "main": [
        [
          {
            "node": "Download Attachments",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Xero - Upload Attachment1": {
      "main": [
        [
          {
            "node": "Add Label",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Contact1": {
      "main": [
        [
          {
            "node": "Create Invoice1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model1": {
      "ai_languageModel": [
        [
          {
            "node": "Information Extractor1",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "If Invoice1": {
      "main": [
        [
          {
            "node": "Xero - Get Chart of Accounts1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If Non Specific Email1": {
      "main": [
        [
          {
            "node": "Xero - Search Supplier1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Get Account Details1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Xero - Search Supplier1": {
      "main": [
        [
          {
            "node": "If Contact Exists (Name Match)1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set ContactID1": {
      "main": [
        [
          {
            "node": "Create Invoice1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Contact - No Email1": {
      "main": [
        [
          {
            "node": "Create Invoice1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Contact ID1": {
      "main": [
        [
          {
            "node": "Create Invoice1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If Contact Exists (Email)1": {
      "main": [
        [
          {
            "node": "Set ContactID1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Create Contact1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If Contact Exists (Name Match)1": {
      "main": [
        [
          {
            "node": "Set Contact ID1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Create Contact - No Email1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Xero - Get Chart of Accounts1": {
      "main": [
        [
          {
            "node": "Information Extractor1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download Attachments": {
      "main": [
        [
          {
            "node": "Xero - Upload Attachment1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "757b4974-cf6b-4542-a066-6994c5a7057d",
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": ""
  },
  "id": "H7BxY2ZI4hRlpVl4",
  "tags": []
}