{
  "id": "NUlutFcBUpLFVrys",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Simple Scheduling and Internal Document Query Bot with Telegram",
  "tags": [],
  "nodes": [
    {
      "id": "4d3060c3-e14b-40a6-b5fe-a8197a821691",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2464,
        -240
      ],
      "parameters": {
        "width": 892,
        "height": 1520,
        "content": "## Try it !\n### This n8n template shows how to use AI with MCP to query internal IT shop documents, enabling scheduling, price checks, and company information in a single workflow.\n\n### Examples: schedule laptop maintenance, check service prices (SSD/RAM upgrades), view company details (history, mission, service area), or access troubleshooting guides for technical support.\n\n### How it works\n* User interacts with the bot via Telegram (or another connected channel).\n* The AI Agent processes the text and detects intent:\n\t* Scheduling \u2192 creates/queries events in Google Calendar\n\t* Price check \u2192 retrieves values from Google Sheets\n\t* Company info \u2192 queries Google Docs\n\t* Troubleshooting \u2192 accesses support sheet with diagnostic steps\n* The agent replies clearly and helpfully to the user.\n\n### How to use\n* Telegram Trigger is included as an example, but you can replace it with WhatsApp, Webhook, or form integrations.\n* The workflow can be expanded with more documents, services, or channels.\n* Agents can be segmented (e.g., receptionist \u2192 specialized agents) for modular and scalable flows.\n\n\n### Requiriments\n* Google account with access to Calendar, Docs, and Sheets\n* MCP Server configured to connect these services\n* Telegram integration node (or other input/output channel)\n* Upstash account for Redis memory\n\n### Next versions (planned)\n* Separate specialized agents (scheduling, pricing, troubleshooting) for modularity\n* Voice support in Telegram (voice input/output for scheduling)\n* More advanced RAG with embeddings and vector databases (Pinecone, Weaviate, Milvus) for smarter document queries\n* Expansion of internal documents and integration with more support tools\n\n\n### Need Help ?\nJoin the Discord or ask in the Forum!\n\ud83d\ude80 Happy automations! \n\ud83d\udcbb Happy Hacking!"
      },
      "typeVersion": 1
    },
    {
      "id": "3f452786-9d2d-4b52-bc3c-a587c6e48b05",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1456,
        -224
      ],
      "parameters": {
        "color": 7,
        "width": 1112,
        "height": 764,
        "content": "## 1. Message Reception, Processing, and Output (Telegram + AI Agent)\n* Telegram Trigger captures the user\u2019s text input.\n* AI Agent interprets the user\u2019s intent and keeps conversation context with memory.\n* MCP Clients connect to MCP Servers, enabling the agent to call external tools (Google Calendar, Docs, Sheets).\n* Upstash Redis stores the conversation history, ensuring continuity across interactions.\n* Result: The agent decides whether to handle scheduling, price queries, or company information."
      },
      "typeVersion": 1
    },
    {
      "id": "f362363a-c07a-43c4-940d-52ae16484061",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -48,
        -160
      ],
      "parameters": {
        "color": 7,
        "width": 864,
        "height": 572,
        "content": "## 2. Scheduling (Google Calendar via MCP)\nDescription: Handles all scheduling operations.\nWhen the AI Agent detects a scheduling intent, it triggers the MCP Client connected to Google Calendar."
      },
      "typeVersion": 1
    },
    {
      "id": "a7c41d2c-70b7-42a7-a153-b768057d07db",
      "name": "MCP Google Docs e Sheet",
      "type": "@n8n/n8n-nodes-langchain.mcpTrigger",
      "position": [
        64,
        800
      ],
      "parameters": {
        "path": "788f0982-a21e-4f27-a571-c033cf81998c"
      },
      "typeVersion": 2
    },
    {
      "id": "039e0bd6-d650-4717-b2b1-7b97392923eb",
      "name": "Troubleshooting - Lista de Problemas e Solu\u00e7\u00f5es",
      "type": "n8n-nodes-base.googleSheetsTool",
      "position": [
        448,
        976
      ],
      "parameters": {
        "options": {},
        "sheetName": {
          "__rl": true,
          "mode": "name",
          "value": "=Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1uiOpslH6Yc3WUJajrUhHZkFRtNftnCpN5ZzssHijB7M",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1uiOpslH6Yc3WUJajrUhHZkFRtNftnCpN5ZzssHijB7M/edit?usp=drivesdk",
          "cachedResultName": "Laptop Troubleshooting"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "d21cade2-8e66-4c2d-9b84-ce57e7a920c3",
      "name": "Valores dos Servi\u00e7os",
      "type": "n8n-nodes-base.googleSheetsTool",
      "position": [
        240,
        992
      ],
      "parameters": {
        "options": {},
        "sheetName": {
          "__rl": true,
          "mode": "name",
          "value": "=Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1VfVE7MgITQjTNuwVW0yrWtDzFd270IbELFdiCiZBZ2I",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1VfVE7MgITQjTNuwVW0yrWtDzFd270IbELFdiCiZBZ2I/edit?usp=drivesdk",
          "cachedResultName": "Valores dos Servi\u00e7os"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "821abc33-a02f-4d6e-94c4-2dc88ef4e50d",
      "name": "Guia da Loja de TI",
      "type": "n8n-nodes-base.googleDocsTool",
      "position": [
        32,
        992
      ],
      "parameters": {
        "operation": "get",
        "documentURL": "https://docs.google.com/document/d/1jKjR1R5OeEXLHdSmVdcSpkMdvU7hzzC_VABGmv-c31w/edit?tab=t.0"
      },
      "credentials": {
        "googleDocsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "262064ad-734c-4c9c-b588-2ca496d8af45",
      "name": "MCP Client Google Calendario",
      "type": "@n8n/n8n-nodes-langchain.mcpClientTool",
      "position": [
        -768,
        288
      ],
      "parameters": {
        "options": {},
        "endpointUrl": "https://cursobotcomia3.app.n8n.cloud/mcp/230cb421-cb8a-42d0-ba9c-2c1cb2cf0ea1"
      },
      "typeVersion": 1.2
    },
    {
      "id": "4cc3422f-ccee-471e-8ee8-c6e86b2cd5e3",
      "name": "MCP Client Google Docs",
      "type": "@n8n/n8n-nodes-langchain.mcpClientTool",
      "position": [
        -1008,
        272
      ],
      "parameters": {
        "options": {},
        "endpointUrl": "https://cursobotcomia3.app.n8n.cloud/mcp/64acdb46-fc52-4862-a44b-945f5ee39160"
      },
      "typeVersion": 1.2
    },
    {
      "id": "1db747fc-019f-44f1-8ec3-53ab1564059a",
      "name": "Date & Time",
      "type": "n8n-nodes-base.dateTimeTool",
      "position": [
        -896,
        240
      ],
      "parameters": {
        "options": {},
        "outputFieldName": "={{ $now }}"
      },
      "typeVersion": 2
    },
    {
      "id": "bd1fe62b-3227-4adb-9a3b-965c6a4159d5",
      "name": "Send a text message",
      "type": "n8n-nodes-base.telegram",
      "position": [
        -784,
        16
      ],
      "parameters": {
        "text": "={{ $json.output }}",
        "chatId": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "41a71b85-4d42-47e6-8153-45840d48a944",
      "name": "Telegram Trigger",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        -1376,
        16
      ],
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "f0979cce-8c53-46c7-8391-b72f1aa719bd",
      "name": "Update an event in Google Calendar",
      "type": "n8n-nodes-base.googleCalendarTool",
      "disabled": true,
      "position": [
        592,
        208
      ],
      "parameters": {
        "eventId": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Event_ID', ``, 'string') }}",
        "calendar": {
          "__rl": true,
          "mode": "list",
          "value": "user@example.com",
          "cachedResultName": "user@example.com"
        },
        "operation": "update",
        "updateFields": {
          "end": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('End', ``, 'string') }}",
          "start": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Start', ``, 'string') }}",
          "summary": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Summary', ``, 'string') }}",
          "description": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Description', ``, 'string') }}"
        }
      },
      "credentials": {
        "googleCalendarOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "68956788-cc31-4c85-94b5-b5a5c2c4f74c",
      "name": "Get many events in Google Calendar",
      "type": "n8n-nodes-base.googleCalendarTool",
      "position": [
        208,
        208
      ],
      "parameters": {
        "options": {},
        "timeMax": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Before', ``, 'string') }}",
        "timeMin": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('After', ``, 'string') }}",
        "calendar": {
          "__rl": true,
          "mode": "list",
          "value": "user@example.com",
          "cachedResultName": "user@example.com"
        },
        "operation": "getAll"
      },
      "credentials": {
        "googleCalendarOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "27a882b6-9938-4cf4-b0ea-e147ed1c6bbd",
      "name": "Delete an event in Google Calendar",
      "type": "n8n-nodes-base.googleCalendarTool",
      "position": [
        400,
        208
      ],
      "parameters": {
        "eventId": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Event_ID', ``, 'string') }}",
        "options": {
          "sendUpdates": ""
        },
        "calendar": {
          "__rl": true,
          "mode": "list",
          "value": "user@example.com",
          "cachedResultName": "user@example.com"
        },
        "operation": "delete"
      },
      "credentials": {
        "googleCalendarOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "cc028ab9-0ed8-484b-a5bf-29c3f005374c",
      "name": "Create an event in Google Calendar",
      "type": "n8n-nodes-base.googleCalendarTool",
      "position": [
        32,
        208
      ],
      "parameters": {
        "end": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('End', ``, 'string') }}",
        "start": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Start', ``, 'string') }}",
        "calendar": {
          "__rl": true,
          "mode": "list",
          "value": "user@example.com",
          "cachedResultName": "user@example.com"
        },
        "additionalFields": {
          "summary": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Summary', ``, 'string') }}",
          "description": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Description', ``, 'string') }}"
        }
      },
      "credentials": {
        "googleCalendarOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "e542a11f-c3f1-460a-ba1f-5ecacc66ca52",
      "name": "MCP Google Calendario",
      "type": "@n8n/n8n-nodes-langchain.mcpTrigger",
      "position": [
        208,
        -16
      ],
      "parameters": {
        "path": "eab60d58-ef0e-443b-8063-778dde013de0"
      },
      "typeVersion": 2
    },
    {
      "id": "d45e253e-2acd-467b-9ddb-4846965579c3",
      "name": "Google Gemini Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        -1296,
        208
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "a4b1a393-7a80-4df4-b3d7-a48387e5cf1a",
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -1136,
        16
      ],
      "parameters": {
        "text": "={{ $json.message.text }}",
        "options": {
          "systemMessage": "<role> Voc\u00ea \u00e9 o Agente de IA da Loja de TI. Sua fun\u00e7\u00e3o \u00e9 atender clientes de forma simp\u00e1tica e profissional, interpretando suas solicita\u00e7\u00f5es e consultando documentos internos via MCP (Google Calendar, Google Docs e Google Sheets). </role>\n\n<instructions> <goal> Seu objetivo \u00e9 ajudar clientes da Loja de TI com: - Agendamento de servi\u00e7os via Google Calendar - Consulta de pre\u00e7os e produtos via Google Sheets - Consulta de informa\u00e7\u00f5es institucionais e orienta\u00e7\u00f5es via Google Docs </goal>\n\n<context> Ferramentas dispon\u00edveis:\n\nGoogle Calendar (MCP) \u2022 Criar, listar, atualizar ou excluir eventos \u2022 Converter datas relativas (\"hoje\", \"amanh\u00e3\", \"semana que vem\") em datas absolutas ISO antes de consultar\n\nGoogle Sheets (MCP) \u2022 Consultar tabela de servi\u00e7os e produtos com valores \u2022 Responder perguntas como \"Quanto custa a troca de HD para SSD?\" ou \"Qual o pre\u00e7o da consultoria em infraestrutura?\"\n\nGoogle Docs (MCP) \u2022 Consultar o guia institucional da Loja de TI \u2022 Responder perguntas sobre hist\u00f3ria da empresa, regi\u00e3o de atendimento, miss\u00e3o, especializa\u00e7\u00f5es e diferenciais\n\nDate & Time Tool \u2022 Sempre consultar esta ferramenta para obter a data atual completa (dia, m\u00eas e ano) \u2022 Usar este valor como refer\u00eancia para interpretar datas relativas \u2022 Regras:\n\n\"hoje\" \u2192 data atual fornecida pela ferramenta\n\n\"amanh\u00e3\" \u2192 +1 dia\n\n\"depois de amanh\u00e3\" \u2192 +2 dias\n\n\"semana que vem\" \u2192 +7 dias \u2022 Converter sempre para formato ISO antes de enviar ao Calendar (ex.: 2025-11-25T00:00:00 at\u00e9 2025-11-25T23:59:59)\n\nBoas pr\u00e1ticas:\n\nResponder de forma clara, amig\u00e1vel e educativa\n\nSempre responder em texto simples (plain text), sem usar Markdown ou HTML\n\nExplicar ao usu\u00e1rio como a informa\u00e7\u00e3o foi obtida (ex.: \"Consultei nossa tabela de servi\u00e7os no Google Sheets...\")\n\nSempre seguir o fluxo: interpretar \u2192 consultar ferramenta \u2192 responder </context>\n\n<output_format> Responda apenas em texto simples, sem Markdown ou HTML. Responda de forma clara, amig\u00e1vel e objetiva. - Para agendamentos: confirmar data/hora e criar evento no Calendar - Para pre\u00e7os: consultar planilha e informar valor com clareza - Para informa\u00e7\u00f5es institucionais: consultar documento e responder com base no guia - Sempre apresentar o resultado de forma compreens\u00edvel e profissional </output_format>\n\n<examples> \u2022 Usu\u00e1rio: \"Quais hor\u00e1rios est\u00e3o livres amanh\u00e3 para manuten\u00e7\u00e3o?\" \u2192 Consultar Date & Time Tool para obter a data atual, calcular +1 dia, converter para ISO e consultar Google Calendar.\n\n\u2022 Usu\u00e1rio: \"Quanto custa a troca de HD para SSD?\" \u2192 Consultar Google Sheets e responder: \"O valor \u00e9 R$ 450,00.\"\n\n\u2022 Usu\u00e1rio: \"Voc\u00eas atendem fora de S\u00e3o Paulo?\" \u2192 Consultar Google Docs e responder: \"Atendemos principalmente a regi\u00e3o metropolitana de S\u00e3o Paulo, mas tamb\u00e9m oferecemos suporte remoto em todo o Brasil.\" </examples> </instructions>"
        },
        "promptType": "define"
      },
      "typeVersion": 2.2
    },
    {
      "id": "da7d8bc5-5548-4995-9325-e42fb2a8baf8",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -112,
        496
      ],
      "parameters": {
        "color": 7,
        "width": 960,
        "height": 700,
        "content": "## 3. Internal Queries (Google Docs & Google Sheets via MCP)\nDescription: Handles queries about internal IT shop information.\n\nGoogle Sheets: Used to retrieve service and product prices.\n   Example: \u201cHow much does SSD upgrade cost?\u201d \u2192 returns $450.\n\nGoogle Docs: Used to access the company\u2019s institutional guide.\n    Example: \u201cDo you serve outside S\u00e3o Paulo?\u201d \u2192 returns service area and remote support info.\n\nTroubleshooting Sheets: Provide diagnostic steps to help users solve technical issues with laptops.\n\n"
      },
      "typeVersion": 1
    },
    {
      "id": "c12d1e8e-69c5-4fb1-87ec-c0eeb85956bc",
      "name": "Redis Chat Memory",
      "type": "@n8n/n8n-nodes-langchain.memoryRedisChat",
      "position": [
        -1136,
        208
      ],
      "parameters": {
        "sessionKey": "={{ $json.message.chat.id.toString() }}",
        "sessionIdType": "customKey",
        "contextWindowLength": 10
      },
      "credentials": {
        "redis": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.5
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "1be68932-6ca5-4a20-8c3f-6978ab067648",
  "connections": {
    "AI Agent": {
      "main": [
        [
          {
            "node": "Send a text message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Date & Time": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Telegram Trigger": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Redis Chat Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Guia da Loja de TI": {
      "ai_tool": [
        [
          {
            "node": "MCP Google Docs e Sheet",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Valores dos Servi\u00e7os": {
      "ai_tool": [
        [
          {
            "node": "MCP Google Docs e Sheet",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "MCP Client Google Docs": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "MCP Client Google Calendario": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Create an event in Google Calendar": {
      "ai_tool": [
        [
          {
            "node": "MCP Google Calendario",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Delete an event in Google Calendar": {
      "ai_tool": [
        [
          {
            "node": "MCP Google Calendario",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Get many events in Google Calendar": {
      "ai_tool": [
        [
          {
            "node": "MCP Google Calendario",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Update an event in Google Calendar": {
      "ai_tool": [
        [
          {
            "node": "MCP Google Calendario",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Troubleshooting - Lista de Problemas e Solu\u00e7\u00f5es": {
      "ai_tool": [
        [
          {
            "node": "MCP Google Docs e Sheet",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    }
  }
}