Telegram event scheduling bot
This flow is used to schedule events in Google Calendar via an integration with Telegram
graph TD
%%{init: {'theme': 'mc','layout': 'elk'}}%%
TelegramWebhook-no237[Telegram Webhook]
style TelegramWebhook-no237 stroke:#a170ff
ParseData-e810l[<div><img src="/_astro/braces.Djq0PW4_.svg" style="height: 20px !important;width: 20px !important"/></div>Parse Message]
style ParseData-e810l stroke:#a170ff
LanggraphReactAgent-ml7hk[Agent]
style LanggraphReactAgent-ml7hk stroke:#a170ff
TelegramMessage-m4cr5[Telegram Message]
style TelegramMessage-m4cr5 stroke:#a170ff
googlecalendarcomponent-xva04[Crear Eventos]
style googlecalendarcomponent-xva04 stroke:#a170ff
GoogleGenerativeAIModel-cx7b4[Gemini]
style GoogleGenerativeAIModel-cx7b4 stroke:#a170ff
TelegramWebhook-no237 -.- ParseData-e810l
linkStyle 0 stroke:#a170ff
ParseData-e810l -.- LanggraphReactAgent-ml7hk
linkStyle 1 stroke:#a170ff
GoogleGenerativeAIModel-cx7b4 -.- LanggraphReactAgent-ml7hk
linkStyle 2 stroke:#a170ff
TelegramMessage-m4cr5 -.- LanggraphReactAgent-ml7hk
linkStyle 3 stroke:#a170ff
googlecalendarcomponent-xva04 -.- LanggraphReactAgent-ml7hk
linkStyle 4 stroke:#a170ff
Telegram Event‑Scheduling Bot Documentation
🧩 Overview
The Telegram event‑scheduling bot automates the creation of Google Calendar events directly from a chat on Telegram.
When a user sends a natural‑language request, the bot parses the message, uses a Gemini language model to interpret the intent, selects the appropriate tool (Telegram reply or Google Calendar operation), and executes it. The workflow ends with a clear confirmation or error message sent back to the user.
⚙️ Main Features
- Telegram webhook to receive user messages in real time.
- Message parsing that extracts chat ID, message ID, and user text.
- Gemini‑powered agent that understands intent, plans actions, and produces structured responses.
- Telegram‑message tool to reply to users directly from the agent.
- Google Calendar tool that creates, updates, or queries events in a specified calendar.
- End‑to‑end integration that eliminates manual copy‑and‑paste and ensures consistent date/time formatting.
🔄 Workflow Steps
| Component Name | Role in the Workflow | Key Inputs | Key Outputs |
|---|---|---|---|
| Telegram Webhook | Receives incoming Telegram messages and converts the webhook payload into a structured Message object. | - Telegram JSON payload (provided by Telegram) | Message (Telegram message), Data (raw webhook data) |
| Parse Data | Formats the raw webhook data into plain text using a predefined template, exposing the user’s message text. | Data (from Telegram Webhook) | Text (plain user message) |
| Gemini | Generates a language model response, providing the text that drives the agent’s reasoning. | Text (from Parse Data) | Text (Gemini output) |
| Langgraph React Agent | Orchestrates the conversation, selects tools based on intent, and executes them. | Input Value (Gemini output), LLM (Gemini model), Tools (Telegram Message, Google Calendar) | Response (final agent reply) |
| Telegram Message | Tool that sends a reply back to the user on Telegram. | Chat ID, Text (from agent response) | Telegram Response (sent message confirmation) |
| Google Calendar | Tool that creates or updates a calendar event according to the parsed intent. | Operation (Create/Update), Calendar ID, Event Details (summary, start/end times, attendees, etc.) | Data (event creation result) |
🧠 Notes
- The bot relies on valid Telegram Bot API credentials and Google Calendar OAuth tokens, configured as hidden credential fields.
- Date and time values for calendar events must follow ISO‑8601 (e.g.,
YYYY-MM-DDfor all‑day events orYYYY-MM-DDTHH:MM:SSfor timed events). - The Gemini model is configured with a temperature of 1 and no special top‑k or top‑p settings; adjust these if a different response style is desired.
- The agent’s system prompt enforces strict date formatting and instructs the model to send final messages back to Telegram.
- The workflow currently supports a single‑message conversation; for multi‑turn interactions, enable the agent’s memory settings (
message_memory). - If the calendar operation fails, the agent should fall back to sending an error message via the Telegram Message tool.
End of Documentation