{
  "name": "Categorize Airtable invoices with OpenAI and TOON token optimization",
  "nodes": [
    {
      "id": "babf989a-7fd3-4dd1-b451-f3c849722a07",
      "name": "OpenAI Enhancement",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        2144,
        1440
      ]
    },
    {
      "id": "7f537c67-d5b8-40e5-8212-844ea91c13a7",
      "name": "JSON to TOON",
      "type": "@custom-js/n8n-nodes-pdf-toolkit.jsonToToon",
      "position": [
        1984,
        1440
      ]
    },
    {
      "id": "baf16dab-4b75-4c13-bae6-bb9bd59d802c",
      "name": "When clicking ‘Execute workflow’",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        384,
        1456
      ]
    },
    {
      "id": "4dd1d8ee-d620-4095-9d3b-5b962f7a17d1",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -912,
        848
      ],
      "parameters": {
        "width": 1120,
        "height": 1776,
        "content": "# Categorizing invoices with TOON optimization\n\nHere is an example of how you can categorize all \nyour invoices in Airtable, from our [invoice creation example](https://n8n.io/workflows/9772-automatic"
      }
    },
    {
      "id": "db143ee8-cab9-49af-97d3-a1b839499058",
      "name": "Get Ready Invoices",
      "type": "n8n-nodes-base.airtable",
      "position": [
        592,
        1456
      ]
    },
    {
      "id": "cc0fabf3-3634-4799-acab-b50a9c0f1459",
      "name": "Get Clients",
      "type": "n8n-nodes-base.airtable",
      "position": [
        1472,
        1440
      ]
    },
    {
      "id": "fc2f2761-8bc4-4151-b508-f0be45e40eae",
      "name": "Get Invoice Items",
      "type": "n8n-nodes-base.airtable",
      "position": [
        976,
        1568
      ]
    },
    {
      "id": "c4a6c493-dbee-4ef3-8c02-74a5609f2f4f",
      "name": "Aggregate",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        1296,
        1568
      ]
    },
    {
      "id": "9a8696bd-459d-49a9-b848-e68a0c0a6e9c",
      "name": "Loop Over Items",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        800,
        1456
      ]
    },
    {
      "id": "3bbef89f-1f29-4cc9-9bbf-a2cb64022b37",
      "name": "Update record",
      "type": "n8n-nodes-base.airtable",
      "position": [
        2720,
        1440
      ]
    },
    {
      "id": "70a430e2-932f-41e3-a431-ce3b0e70ef0e",
      "name": "Map Fields",
      "type": "n8n-nodes-base.set",
      "position": [
        1136,
        1568
      ]
    },
    {
      "id": "7689029a-47eb-4aa3-b296-cfe4ae9e0d7b",
      "name": "GroupClientAndInvoice",
      "type": "n8n-nodes-base.set",
      "position": [
        1776,
        1440
      ]
    },
    {
      "id": "68528c43-c25e-4941-9e47-e12c65550214",
      "name": "TOON to JSON",
      "type": "@custom-js/n8n-nodes-pdf-toolkit.toonToJson",
      "position": [
        2432,
        1440
      ]
    },
    {
      "id": "0a0c52fb-2716-4a13-a2a7-bf5457744edc",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        320,
        1376
      ],
      "parameters": {
        "width": 1296,
        "height": 416,
        "content": "## Collect invoice data from Airtable"
      }
    },
    {
      "id": "f1346b90-3f73-4b36-a52a-06139c7ee7d0",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1744,
        1376
      ],
      "parameters": {
        "width": 832,
        "height": 416,
        "content": "## Categorizing Invoices"
      }
    },
    {
      "id": "e3650253-bfd2-4307-af75-66015c69e265",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2672,
        1376
      ],
      "parameters": {
        "width": 432,
        "height": 416,
        "content": "## Save categories back to Airtable"
      }
    }
  ],
  "connections": {
    "Aggregate": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Map Fields": {
      "main": [
        [
          {
            "node": "Aggregate",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Clients": {
      "main": [
        [
          {
            "node": "GroupClientAndInvoice",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "JSON to TOON": {
      "main": [
        [
          {
            "node": "OpenAI Enhancement",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "TOON to JSON": {
      "main": [
        [
          {
            "node": "Update record",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [
          {
            "node": "Get Clients",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Get Invoice Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Invoice Items": {
      "main": [
        [
          {
            "node": "Map Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Ready Invoices": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Enhancement": {
      "main": [
        [
          {
            "node": "TOON to JSON",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "GroupClientAndInvoice": {
      "main": [
        [
          {
            "node": "JSON to TOON",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking ‘Execute workflow’": {
      "main": [
        [
          {
            "node": "Get Ready Invoices",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}