Hi Makers! ![]()
Why I built this
I needed a way to get quick AI answers without switching between apps. Telegram is where I already spend most of my time, so I wanted an assistant that could answer both typed questions and voice messages directly inside a chat.
Result: The bot now replies to text and voice messages within a few seconds, and it has been running since [2026.08.01] handling around [50] messages per day.
How the scenario works
1. Telegram → Watch Updates (trigger)
This module listens for every new message sent to the bot. It returns the full message object, which can contain either a text field or a voice field.
2. Router → two branches
I used a Router because text and voice need completely different handling. Each route has its own filter:
- Route A (Text): filter →
textexists - Route B (Voice): filter →
voiceexists
Without the Router, the scenario would try to transcribe text messages and fail.
3. Route B — Voice processing
- Telegram → Get a File: Telegram only sends a
file_id, not the audio itself, so this step retrieves the actual file path. - HTTP → Get a File: downloads the
.ogaaudio as binary data. - converts the audio into text.
After this step, both routes carry plain text, so they can be merged into the same AI module.
4. AI response generation
The transcribed or typed text is sent to [نام مدل، مثلاً Google Gemini] with a system prompt that keeps answers short and conversational, because long replies are hard to read on mobile.
5. Telegram → Send a Message
The AI output is sent back to the same chat_id from the trigger, so the reply always lands in the correct conversation.
What I learned
- Voice messages require two separate download steps in Telegram (get the file path, then download the file) — this is not obvious at first.
- Putting the filter on the Router instead of inside each branch made the scenario much easier to debug.
- Keeping the system prompt short noticeably reduced token usage and response time.
Scenario link
Hope this helps someone building something similar! ![]()




