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 Agent
2from kern.models.openai import OpenAIResponses
3from kern.os.app import AgentOS
4from kern.os.interfaces.telegram import Telegram
5
6agent = Agent(name="Assistant", model=OpenAIResponses(id="gpt-5.4"))
7
8agent_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 7777

How It Works

ConceptBehavior
SessionsEach chat is a session (tg:{agent}:{chat_id}). Send /new to reset.
StreamingToken-by-token with live message edits, throttled for rate limits
GroupsResponds to @mentions and replies by default. Disable privacy mode in BotFather for all messages.
MediaPhotos, 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

Next Steps