{
  "name": "Expense Tracker",
  "nodes": [
    {
      "parameters": {
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "typeVersion": 1.1,
      "position": [
        0,
        0
      ],
      "id": "3a151e43-3a25-47a8-80de-a873d6ed5b52",
      "name": "When chat message received"
    },
    {
      "parameters": {
        "options": {
          "systemMessage": "You are a helpful assistant. You are used to save expenses or income. Always refer to 2025 year.",
          "maxIterations": 3
        }
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 1.9,
      "position": [
        220,
        0
      ],
      "id": "96089dcd-7ae1-4d4e-85b0-8d9961855ac0",
      "name": "AI Agent"
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini"
        },
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.2,
      "position": [
        140,
        220
      ],
      "id": "8b04ef29-81c4-4145-aa5a-19a09db949c8",
      "name": "OpenAI Chat Model",
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {},
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "typeVersion": 1.3,
      "position": [
        320,
        220
      ],
      "id": "6926b20b-38a7-4c88-a6de-1a246355f819",
      "name": "Simple Memory"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "ca1c59e3-e8df-4425-b3c4-f9a91f90babe",
              "name": "response",
              "value": "=response {{ $('When chat message received').item.json.chatInput }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        580,
        0
      ],
      "id": "552065e1-136f-4ab5-8280-807d99411195",
      "name": "Edit Fields"
    },
    {
      "parameters": {
        "name": "expense_database",
        "description": "call this tool to save the expences to database",
        "workflowId": {
          "__rl": true,
          "value": "Z2prdLuqZHmRjAap",
          "mode": "id"
        },
        "workflowInputs": {
          "mappingMode": "defineBelow",
          "value": {},
          "matchingColumns": [],
          "schema": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        }
      },
      "type": "@n8n/n8n-nodes-langchain.toolWorkflow",
      "typeVersion": 2.1,
      "position": [
        480,
        220
      ],
      "id": "77a0fc40-c03a-4cc3-9c3e-2b3c37247d90",
      "name": "Call n8n Workflow Tool"
    },
    {
      "parameters": {
        "text": "=convert expense to JSON:\n\n {{ $json.query }}",
        "attributes": {
          "attributes": [
            {
              "name": "cost",
              "type": "number",
              "description": "expense cost",
              "required": true
            },
            {
              "name": "description",
              "description": "expense or income description",
              "required": true
            },
            {
              "name": "date",
              "type": "date",
              "description": "date in UTC+2",
              "required": true
            },
            {
              "name": "type",
              "description": "If is an expense or income",
              "required": true
            }
          ]
        },
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.informationExtractor",
      "typeVersion": 1,
      "position": [
        220,
        540
      ],
      "id": "3809c715-7f2d-48fe-b040-83f20aa1d875",
      "name": "Information Extractor"
    },
    {
      "parameters": {
        "inputSource": "passthrough"
      },
      "type": "n8n-nodes-base.executeWorkflowTrigger",
      "typeVersion": 1.1,
      "position": [
        0,
        540
      ],
      "id": "43b2b9bf-f72b-4204-9055-41ad027147b7",
      "name": "When Executed by Another Workflow"
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini"
        },
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.2,
      "position": [
        200,
        760
      ],
      "id": "95bacb6a-c380-4a61-aa39-0222d0b6ce24",
      "name": "OpenAI Chat Model1",
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "append",
        "documentId": {
          "__rl": true,
          "value": "1Pq_hkKnThRvHKEQxANeTS5HHSZ08Vv-3brfVGc4jyIo",
          "mode": "list",
          "cachedResultName": "My Expenses",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1Pq_hkKnThRvHKEQxANeTS5HHSZ08Vv-3brfVGc4jyIo/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Sheet1",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1Pq_hkKnThRvHKEQxANeTS5HHSZ08Vv-3brfVGc4jyIo/edit#gid=0"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "Description": "={{ $json.output.description }}",
            "Cost": "={{ $json.output.cost }}",
            "Date": "={{ $json.output.date }}",
            "Type": "={{ $json.output.type }}"
          },
          "matchingColumns": [],
          "schema": [
            {
              "id": "Description",
              "displayName": "Description",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Cost",
              "displayName": "Cost",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Date",
              "displayName": "Date",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Type",
              "displayName": "Type",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        580,
        540
      ],
      "id": "6d556fd2-4a2e-4961-84cb-4f4df73094e3",
      "name": "Google Sheets",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "content": "# Handle Expences or Income",
        "height": 500,
        "width": 840
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -60,
        -120
      ],
      "id": "254a2012-5e6c-4667-b92e-793480d3074d",
      "name": "Sticky Note"
    },
    {
      "parameters": {
        "content": "# Save The Data",
        "height": 500,
        "width": 840,
        "color": 5
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -60,
        400
      ],
      "id": "c7333aab-204f-4e50-a9d1-39cb6f0da60e",
      "name": "Sticky Note1"
    }
  ],
  "connections": {
    "When chat message received": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Simple Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent": {
      "main": [
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Call n8n Workflow Tool": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "When Executed by Another Workflow": {
      "main": [
        [
          {
            "node": "Information Extractor",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model1": {
      "ai_languageModel": [
        [
          {
            "node": "Information Extractor",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Information Extractor": {
      "main": [
        [
          {
            "node": "Google Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "0c5f78c8-9324-4a25-ac87-cc07bd19a7bd",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "id": "Z2prdLuqZHmRjAap",
  "tags": []
}