AI Telegram Bot — multi-modal assistant on Telegram

A Telegram bot that accepts text, voice notes and image requests and routes each to the appropriate AI service: a language model for conversation, speech recognition for voice messages, and an image generator for picture requests.

PythonTelegram Bot APIWhisperEdge-TTSStable DiffusionOpenAI API

What it does

The bot presents a single conversational interface and decides what kind of input it has received before deciding what to do with it.

  • Text messages are answered by a language model
  • Voice notes are transcribed with speech recognition, then answered as text
  • Responses can be returned as synthesised speech rather than text
  • Image generation requests are routed to a diffusion model and the resulting image is sent back into the chat

Why routing is the interesting part

Each capability on its own is a thin wrapper around an API. The engineering work is in deciding which service a given incoming update should reach, and in handling the cases where that decision is slow or fails.

Telegram delivers updates as webhooks or long polling, and voice notes arrive as downloadable files rather than text, so the handler has to fetch the audio, transcribe it, and only then treat the result as a prompt. Image generation is slower than a text reply by orders of magnitude, which means the bot has to acknowledge the request and deliver the result asynchronously rather than assuming a single fast round trip.

Keeping the services independent means a failure in one does not take down the others, and any single provider can be replaced without touching the routing layer.

Stack

The project is written in Python and uses the Telegram Bot API, Whisper for speech recognition, Edge-TTS for speech synthesis, Stable Diffusion for image generation, and a language model API for conversation. Each of those is a separate dependency with its own failure modes, which is why the routing layer is explicit rather than implicit.

At a glance

  • Voice Processing
  • Image Generation
  • Text-to-Speech
  • Multi-modal AI