{
  "name": "Expenses Tracking Agent",
  "nodes": [
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ $json.message.text }}",
        "options": {
          "systemMessage": "You are an efficient accountant. Utilize the 'save to db' tool to log the expense details into the database. Reply with: 'Your expense has been recorded. Here is the output from the save sub-workflow: [data]",
          "maxIterations": 3
        }
      },
      "id": "d997cdbe-bb95-4056-9496-553f3c28fe9d",
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        2860,
        420
      ],
      "typeVersion": 1.7
    },
    {
      "parameters": {
        "options": {}
      },
      "id": "78831059-55ca-4e71-9974-04a1700377a9",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        2840,
        680
      ],
      "typeVersion": 1.1,
      "credentials": {
        "openAiApi": {
          "id": "DBpeXA2IXrXK46lj",
          "name": "n8n free OpenAI API credits"
        }
      }
    },
    {
      "parameters": {
        "sessionIdType": "customKey",
        "sessionKey": "={{ $json.message.chat.id }}"
      },
      "id": "a2a1fade-022f-45ec-b170-508b485a455b",
      "name": "Window Buffer Memory",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        3000,
        680
      ],
      "typeVersion": 1.3
    },
    {
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {}
      },
      "type": "n8n-nodes-base.telegramTrigger",
      "typeVersion": 1.1,
      "position": [
        2620,
        420
      ],
      "id": "79b65e17-ca83-4e2d-9069-5438e9c5559a",
      "name": "Telegram Trigger",
      "webhookId": "76822a25-d738-413b-90cd-27c1e511884d",
      "credentials": {
        "telegramApi": {
          "id": "uO0lVtfdNYsEA99Q",
          "name": "Telegram account"
        }
      }
    },
    {
      "parameters": {
        "name": "save_expense_in_db",
        "description": "Call this tool to save expense in db.",
        "workflowId": {
          "__rl": true,
          "value": "ozseltaNkrZQfJmq",
          "mode": "list",
          "cachedResultName": "Save expense workflow"
        },
        "workflowInputs": {
          "mappingMode": "defineBelow",
          "value": {
            "input1": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('input1', ``, 'string') }}"
          },
          "matchingColumns": [
            "input1"
          ],
          "schema": [
            {
              "id": "input1",
              "displayName": "input1",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "canBeUsedToMatch": true,
              "type": "string"
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        }
      },
      "id": "7d17cbb0-848e-4269-a124-a1e572984926",
      "name": "Save expense workflow",
      "type": "@n8n/n8n-nodes-langchain.toolWorkflow",
      "position": [
        3200,
        660
      ],
      "notesInFlow": true,
      "typeVersion": 2,
      "notes": "Make sure that this SAME workflow is chosen in the Workflow dropdown!"
    }
  ],
  "pinData": {},
  "connections": {
    "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
          }
        ]
      ]
    },
    "Telegram Trigger": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Save expense workflow": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "8caac67d-6c10-42b3-87a8-7d3c287c379a",
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "ae59e6b831344dba624c99cbe778a4bc47150f8e64de86a8011d15bac8e58c21"
  },
  "id": "HooRBhfbblstJ2Sa",
  "tags": []
}