{
  "name": "Invoice Generator",
  "nodes": [
    {
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {}
      },
      "type": "n8n-nodes-base.telegramTrigger",
      "typeVersion": 1.1,
      "position": [
        240,
        -20
      ],
      "id": "701ede7a-7d74-42e5-ac32-1bdc9c694cd0",
      "name": "Telegram Trigger",
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ $json.message.caption }}",
        "options": {
          "systemMessage": "=You are a helpful assistant, named Jono, and your task is to handle intelligent document processing.\n\n##Tools\n1. Call the document_processing tool to handle any OCR for PDF document processing. \n2. Call the image_processsing tool to handle any OCR for image processing. When user calls this tool, please start it immediately. The image will be passed through an ID and processed on the sub-agent. No need to verify"
        }
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 1.7,
      "position": [
        560,
        -20
      ],
      "id": "65665f2c-cbe3-4c61-9b63-37c2b86db5f1",
      "name": "AI Agent"
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini"
        },
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.2,
      "position": [
        460,
        200
      ],
      "id": "48872032-974c-4390-b627-5f644e8a7d3b",
      "name": "OpenAI Chat Model",
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "sessionIdType": "customKey",
        "sessionKey": "={{ $('Telegram Trigger').item.json.message.chat.id }}"
      },
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "typeVersion": 1.3,
      "position": [
        580,
        200
      ],
      "id": "c29faa42-324f-4b18-ac88-ca80f127b9a3",
      "name": "Window Buffer Memory"
    },
    {
      "parameters": {
        "name": "document_processing",
        "description": "Call this tool to pull out any data from a PDF file",
        "workflowId": {
          "__rl": true,
          "value": "9RBCF8EHFlsT3KJ6",
          "mode": "list",
          "cachedResultName": "Document Processing"
        },
        "workflowInputs": {
          "mappingMode": "defineBelow",
          "value": {
            "message": "={{ $('Telegram Trigger').item.json.message.caption }}",
            "id": "={{ $('Telegram Trigger').item.json.message.document.file_id }}"
          },
          "matchingColumns": [
            "data"
          ],
          "schema": [
            {
              "id": "message",
              "displayName": "message",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "canBeUsedToMatch": true,
              "type": "string",
              "removed": false
            },
            {
              "id": "id",
              "displayName": "id",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "canBeUsedToMatch": true,
              "type": "string",
              "removed": false
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        }
      },
      "type": "@n8n/n8n-nodes-langchain.toolWorkflow",
      "typeVersion": 2,
      "position": [
        720,
        200
      ],
      "id": "a5e39bf6-9405-4c2b-ae31-3e67f841e4f8",
      "name": "Document processing"
    },
    {
      "parameters": {
        "chatId": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
        "text": "={{ $json.output }}",
        "additionalFields": {}
      },
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        920,
        -20
      ],
      "id": "bbc510b3-e324-4e95-9b84-501190e73268",
      "name": "Telegram3",
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "name": "image_processing",
        "description": "Call this tool to pull out any data from a image file (JPG, PNG, etc)",
        "workflowId": {
          "__rl": true,
          "value": "m0C4Xan9A80W4bjz",
          "mode": "list",
          "cachedResultName": "Image Processing"
        },
        "workflowInputs": {
          "mappingMode": "defineBelow",
          "value": {
            "message": "={{ $('Telegram Trigger').item.json.message.caption }}",
            "id": "={{ $('Telegram Trigger').item.json.message.document.file_id }}"
          },
          "matchingColumns": [],
          "schema": [
            {
              "id": "message",
              "displayName": "message",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "canBeUsedToMatch": true,
              "type": "string"
            },
            {
              "id": "id",
              "displayName": "id",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "canBeUsedToMatch": true,
              "type": "string",
              "removed": false
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        }
      },
      "type": "@n8n/n8n-nodes-langchain.toolWorkflow",
      "typeVersion": 2,
      "position": [
        860,
        200
      ],
      "id": "1ecfb2ad-1a97-4002-a4b2-43cd0adcab10",
      "name": "Image processing"
    }
  ],
  "connections": {
    "Telegram Trigger": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent": {
      "main": [
        [
          {
            "node": "Telegram3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Window Buffer Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Document processing": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Image processing": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "27290178-0f57-4290-9e03-8db485e4e22a",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "id": "aXhyIQsmRtpgt1Nh",
  "tags": []
}