{
  "name": "Automated invoice processing with Telegram, GPT-4o, OCR and SAP integration",
  "nodes": [
    {
      "id": "026397ff-3b84-49f4-adf1-d4e8bef01e38",
      "name": "Wait",
      "type": "n8n-nodes-base.wait",
      "position": [
        1620,
        100
      ]
    },
    {
      "id": "7c032e9c-edc3-4b23-89d5-66e092b37857",
      "name": "Basic LLM Chain",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        1840,
        -100
      ]
    },
    {
      "id": "036c0443-0224-4a2f-9a9a-c7d9feebbdc3",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        1840,
        80
      ]
    },
    {
      "id": "0af0d3fb-6b87-44b4-8fe8-3c992c74a10d",
      "name": "No Operation, do nothing",
      "type": "n8n-nodes-base.noOp",
      "position": [
        760,
        820
      ]
    },
    {
      "id": "a9201f0b-e504-45c2-ade0-86004ba5e323",
      "name": "Split Out",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        2280,
        -100
      ]
    },
    {
      "id": "8a189ae2-64d4-459b-a8fd-81b4423cf135",
      "name": "Merge",
      "type": "n8n-nodes-base.merge",
      "position": [
        2240,
        540
      ]
    },
    {
      "id": "b13a0de4-a00e-4b38-8b12-fa9c2b1825d9",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -140,
        460
      ],
      "parameters": {
        "width": 3720,
        "height": 560,
        "content": "## Waiting for an answer on telegram"
      }
    },
    {
      "id": "4aa3c30a-4a2c-4168-866d-4e1b8a3651f5",
      "name": "Callback Waiting Answer",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        -40,
        640
      ]
    },
    {
      "id": "8b49790e-fc03-4a1b-944c-139e383a0a46",
      "name": "Answer?",
      "type": "n8n-nodes-base.switch",
      "position": [
        300,
        640
      ]
    },
    {
      "id": "a958d830-0608-4d9b-a14d-922869c9fbd3",
      "name": "Connect to SAP",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        760,
        520
      ]
    },
    {
      "id": "ec4c8074-6aa8-4f89-812c-3d6305a10d60",
      "name": "Get Header",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1160,
        520
      ]
    },
    {
      "id": "5e290a19-236a-4baa-9093-1b32f486b058",
      "name": "Get Row Details",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1560,
        680
      ]
    },
    {
      "id": "42edf631-ee30-4b6f-b10b-fa53ee148c26",
      "name": "Generate DocumentLines",
      "type": "n8n-nodes-base.code",
      "position": [
        1880,
        680
      ]
    },
    {
      "id": "d9d54a86-50e7-469a-88a2-c5860459bf99",
      "name": "Create JSON",
      "type": "n8n-nodes-base.code",
      "position": [
        2580,
        540
      ]
    },
    {
      "id": "dfbd5b4b-a545-4062-bfdb-1d383c8277f6",
      "name": "POST PurchaseInvoices",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2980,
        540
      ]
    },
    {
      "id": "ec33a3bf-2632-4f49-b0c8-4fe1284c90df",
      "name": "PurchaseInvoices created",
      "type": "n8n-nodes-base.telegram",
      "position": [
        3360,
        540
      ]
    },
    {
      "id": "311d3616-3ebf-439f-8d6f-f5aa18e89bc6",
      "name": "Trigger Receive Message",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        0,
        0
      ]
    },
    {
      "id": "c01eb2e3-7aa8-4a4c-897f-4414816fa459",
      "name": "Capture Telegram Data",
      "type": "n8n-nodes-base.set",
      "position": [
        260,
        0
      ]
    },
    {
      "id": "bacef005-e65c-4894-aa0b-8ef34033daac",
      "name": "File Received",
      "type": "n8n-nodes-base.telegram",
      "position": [
        500,
        0
      ]
    },
    {
      "id": "01bae880-e0d1-449f-b459-94b7a56b3adb",
      "name": "Download File",
      "type": "n8n-nodes-base.telegram",
      "position": [
        720,
        0
      ]
    },
    {
      "id": "86e1b80a-302d-4010-a740-ce916f8f74df",
      "name": "Upload File LlamaIndex",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        940,
        0
      ]
    },
    {
      "id": "92f93bbd-3192-40aa-b81f-bf5165e3dc35",
      "name": "Validate Status LlamaIndex",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1180,
        0
      ]
    },
    {
      "id": "4914e5d3-ec4e-4c96-b6c1-6f2ede2b5b38",
      "name": "Status?",
      "type": "n8n-nodes-base.switch",
      "position": [
        1400,
        0
      ]
    },
    {
      "id": "d2c19099-01c7-4547-aa3e-944c16009aaf",
      "name": "Get Results LlamaIndex",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1620,
        -100
      ]
    },
    {
      "id": "c0ba5071-56b6-45c0-b0ad-bb87b8c543ca",
      "name": "Structured Output Parser (Example)",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        2060,
        60
      ]
    },
    {
      "id": "f62a9650-a966-4efa-a9ec-ee166e4e3881",
      "name": "Detail",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        2480,
        80
      ]
    },
    {
      "id": "ec718e9d-d729-4493-8439-78cf63394e28",
      "name": "Header",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        2620,
        -100
      ]
    },
    {
      "id": "d30ac579-8f31-471f-89d6-e27b6b99a4f3",
      "name": "¿Upload to SAP?",
      "type": "n8n-nodes-base.telegram",
      "position": [
        2900,
        -100
      ]
    },
    {
      "id": "e80fa814-502a-4af1-8c3f-8b35c65ed0eb",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -120,
        -180
      ],
      "parameters": {
        "width": 3280,
        "height": 540,
        "content": "## Send data and OCR with LlamaIndex\n"
      }
    }
  ],
  "connections": {
    "Wait": {
      "main": [
        [
          {
            "node": "Validate Status LlamaIndex",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge": {
      "main": [
        [
          {
            "node": "Create JSON",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Detail": {
      "main": [
        [
          {
            "node": "Header",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Header": {
      "main": [
        [
          {
            "node": "¿Upload to SAP?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Answer?": {
      "main": [
        [
          {
            "node": "Connect to SAP",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "No Operation, do nothing",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Status?": {
      "main": [
        [
          {
            "node": "Get Results LlamaIndex",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Out": {
      "main": [
        [
          {
            "node": "Detail",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Header": {
      "main": [
        [
          {
            "node": "Get Row Details",
            "type": "main",
            "index": 0
          },
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create JSON": {
      "main": [
        [
          {
            "node": "POST PurchaseInvoices",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download File": {
      "main": [
        [
          {
            "node": "Upload File LlamaIndex",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "File Received": {
      "main": [
        [
          {
            "node": "Download File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Connect to SAP": {
      "main": [
        [
          {
            "node": "Get Header",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Basic LLM Chain": {
      "main": [
        [
          {
            "node": "Split Out",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Row Details": {
      "main": [
        [
          {
            "node": "Generate DocumentLines",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "¿Upload to SAP?": {
      "main": [
        []
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Basic LLM Chain",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Capture Telegram Data": {
      "main": [
        [
          {
            "node": "File Received",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "POST PurchaseInvoices": {
      "main": [
        [
          {
            "node": "PurchaseInvoices created",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate DocumentLines": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Get Results LlamaIndex": {
      "main": [
        [
          {
            "node": "Basic LLM Chain",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Upload File LlamaIndex": {
      "main": [
        [
          {
            "node": "Validate Status LlamaIndex",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Callback Waiting Answer": {
      "main": [
        [
          {
            "node": "Answer?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Trigger Receive Message": {
      "main": [
        [
          {
            "node": "Capture Telegram Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Validate Status LlamaIndex": {
      "main": [
        [
          {
            "node": "Status?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser (Example)": {
      "ai_outputParser": [
        [
          {
            "node": "Basic LLM Chain",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    }
  }
}