Telegram
Deploy agents to Telegram for direct and group chat interactions.
The Telegram interface turns any Kern agent, team, or workflow into a Telegram bot with streaming responses, media handling, and group chat support.
Quick Start
1from kern.agent import Agent2from kern.models.openai import OpenAIResponses3from kern.os.app import AgentOS4from kern.os.interfaces.telegram import Telegram56agent = Agent(name="Assistant", model=OpenAIResponses(id="gpt-5.4"))78agent_os = AgentOS(9 agents=[agent],10 interfaces=[Telegram(agent=agent)],11)12app = agent_os.get_app()1uv pip install 'kern-ai[telegram]'2python -m kern.os.serve telegram_agent:app --port 7777How It Works
| Concept | Behavior |
|---|---|
| Sessions | Each chat is a session (tg:{agent}:{chat_id}). Send /new to reset. |
| Streaming | Token-by-token with live message edits, throttled for rate limits |
| Groups | Responds to @mentions and replies by default. Disable privacy mode in BotFather for all messages. |
| Media | Photos, voice, video, documents, stickers in and out |
Setup
Requires a bot token from @BotFather and a webhook URL. See the full setup guide for step-by-step instructions.
Environment variables:
1export TELEGRAM_TOKEN="..."2export TELEGRAM_WEBHOOK_SECRET_TOKEN="..." # production only