Telegram event management 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 alt="logo" src="/_astro/braces.Djq0PW4_.svg" style="height: 20px !important;width: 20px !important"/></div>Parse Message]
style ParseData-e810l 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
AdvancedAgent-27y8e[Agent]
style AdvancedAgent-27y8e stroke:#a170ff
TelegramWebhook-no237 -.- ParseData-e810l
linkStyle 0 stroke:#a170ff
ParseData-e810l -.- AdvancedAgent-27y8e
linkStyle 1 stroke:#a170ff
TelegramMessage-m4cr5 -.- AdvancedAgent-27y8e
linkStyle 2 stroke:#a170ff
googlecalendarcomponent-xva04 -.- AdvancedAgent-27y8e
linkStyle 3 stroke:#a170ff
GoogleGenerativeAIModel-cx7b4 -.- AdvancedAgent-27y8e
linkStyle 4 stroke:#a170ff
📦 Telegram Event Management Bot
The workflow receives Telegram messages, extracts the request, and uses an advanced AI agent to create Google Calendar events.
It then replies to the user through Telegram, closing the loop in a single automated process.
⚙️ Main Features
- Webhook ingestion of Telegram updates with automated message storage.
- Structured parsing of the incoming JSON to extract chat‑id, message‑id, and text.
- Agent‑driven decision making using Gemini for natural‑language interpretation and tool selection.
- Calendar event creation via the Google Calendar API with support for meeting links.
- Telegram response with the event outcome or error feedback.
- Built‑in memory and streaming options for conversational continuity and real‑time feedback.
🔄 Workflow Steps
| Component Name | Role in the Workflow | Key Inputs | Key Outputs |
|---|---|---|---|
| Telegram Webhook | Receives incoming Telegram updates and stores the message. | Raw webhook JSON containing message data. | Parsed Telegram message object. |
| Parse Message | Transforms the raw Telegram data into plain text and metadata. | Telegram message object. | Textual representation of the user request. |
| Gemini (Google Generative AI) | Provides the language model used by the agent to interpret the request. | Prompt text from the agent. | Generated response text (used by the agent). |
| Google Calendar Component | Creates or updates calendar events based on agent output. | Calendar event details (summary, dates, attendees, etc.). | Confirmation or error message about the calendar operation. |
| Telegram Message | Sends the final reply back to the user via the bot API. | Chat ID, message text, and optional attachments. | Telegram API response confirming message delivery. |
| Advanced Agent | Coordinates tools, manages memory, and generates the final response to be sent. | Parsed user request, available tools (Telegram, Calendar, Gemini), system prompt. | Final agent response message sent to Telegram. |
🧠 Notes
- The webhook component can be configured to store or discard messages; choose according to privacy requirements.
- Parsing assumes the Telegram message follows the standard update format; malformed payloads will halt the flow.
- The agent uses a fallback model list; if the primary Gemini model fails, it automatically switches to an alternative.
- Memory and streaming features are optional but recommended for prolonged interactions or real‑time debugging.
- Calendar operations are subject to Google Calendar API quotas; error handling should capture rate‑limit or permission issues.
- All date and time values must follow ISO 8601 (
YYYY-MM-DDfor full‑day events,YYYY-MM-DDTHH:MM:SSfor timed events).
End of documentation