{
  "name": "Agente de Controle Financeiro",
  "nodes": [
    {
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {}
      },
      "type": "n8n-nodes-base.telegramTrigger",
      "typeVersion": 1.2,
      "position": [
        -304,
        -48
      ],
      "id": "f0357ba0-1abc-4dfb-a7d0-f327069887cd",
      "name": "Telegram Trigger"
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ $json.message.text }}",
        "options": {
          "systemMessage": "=### Regra\n\nVoc\u00ea \u00e9 um rastreador de despesas muito inteligente\n\n## Tarefa:\n\nVoc\u00ea entender\u00e1 a mensagem do usu\u00e1rio e atualizar\u00e1 a planilha de acordo com o que foi enviado pelo usu\u00e1rio\n\n## Instructions:\n\n### Data\n- a data \u00e9: {{ $now.toFormat('dd/MM/yyyy') }}\n\n### Entender os gastos do usu\u00e1rio\n- Entender os detalhes dos gastos atrav\u00e9s da mensagem do usu\u00e1rio. Voc\u00ea precisa preencher as seguintes colunas da planilha: Data, Descri\u00e7\u00e3o, Valor (R$), Tipo\n\n### Atualizando a planilha\n- Use a ferramenta \"Google Sheets\" para atualizar a planilha.\n\n## Restri\u00e7\u00f5es:\n- se alguma coluna n\u00e3o estiver clara, pergunte ao usu\u00e1rio para receber esclarecimento.\n\n## Exemplo da estrutura da planilha:\n\n| Data       | Descri\u00e7\u00e3o | Valor (R$) | Tipo           |\n| 18.08.2025 | Gasolina  | 50.00      | Gasto com carro |\n| 18.08.2025 | Netflix   | 25.99      | Streaming       |\n\nNote: se voc\u00ea conseguir atualizar a planilha, mostre ao usu\u00e1rio que voc\u00ea conseguiu no seguinte formato:\n\nData: 18.08.2025\n\nDescri\u00e7\u00e3o: Gasolina\n\nValor (R$): 50.00\n\nTipo: Gasto com carro\nAgente planejador de conte\u00fados"
        }
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 3.1,
      "position": [
        -96,
        -48
      ],
      "id": "120073d6-4cbf-4b8c-8eaa-1ed3a4327a0c",
      "name": "AI Agent"
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "typeVersion": 1,
      "position": [
        -240,
        160
      ],
      "id": "ed11c096-6cf3-41e2-a067-7dd6a219ea8e",
      "name": "Google Gemini Chat Model"
    },
    {
      "parameters": {
        "sessionIdType": "customKey",
        "sessionKey": "={{ $('Telegram Trigger').item.json.message.chat.id }}"
      },
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "typeVersion": 1.3,
      "position": [
        -80,
        176
      ],
      "id": "f15d24b5-89c9-4975-a17d-6a87c5a42590",
      "name": "Simple Memory"
    },
    {
      "parameters": {
        "operation": "append",
        "documentId": {
          "__rl": true,
          "value": "REPLACE_WITH_YOUR_SPREADSHEET_ID",
          "mode": "list"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "Data": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Data', ``, 'string') }}",
            "Descri\u00e7\u00e3o": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Descri__o', ``, 'string') }}",
            "Tipo": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Tipo', ``, 'string') }}",
            "Valor (R$)": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Valor__R__', ``, 'string') }}"
          },
          "matchingColumns": [],
          "schema": [
            {
              "id": "Data",
              "displayName": "Data",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Descri\u00e7\u00e3o",
              "displayName": "Descri\u00e7\u00e3o",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Valor (R$)",
              "displayName": "Valor (R$)",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Tipo",
              "displayName": "Tipo",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheetsTool",
      "typeVersion": 4.7,
      "position": [
        112,
        144
      ],
      "id": "36640817-15fe-418d-b499-5dae88f96328",
      "name": "Append row in sheet in Google Sheets"
    },
    {
      "parameters": {
        "chatId": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
        "text": "={{ $json.output }}",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        256,
        -48
      ],
      "id": "f1a8a25a-861d-4e72-898f-fb2dd1efb22f",
      "name": "Send a text message"
    }
  ],
  "connections": {
    "Telegram Trigger": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Simple Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Append row in sheet in Google Sheets": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent": {
      "main": [
        [
          {
            "node": "Send a text message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1",
    "availableInMCP": false
  },
  "tags": []
}