OpenCode Telegram Group Topics Bot

April 6, 2026 · View on GitHub

License: MIT Node.js

Languages: English (en), Deutsch (de), Espanol (es), Francais (fr), Russkiy (ru), Jian ti Zhong wen (zh-CN 中文说明)

A Telegram bot for OpenCode that turns one Telegram supergroup into a multi-session mobile workspace.

This project is a fork of the original single-chat bot: grinev/opencode-telegram-bot by Ruslan Grinev.

  • Use the upstream project if you want the simpler single-chat workflow.
  • Use this fork if you want one General control topic plus dedicated forum topics for parallel OpenCode sessions.

No open ports, no exposed web UI. The bot talks only to your local OpenCode server and the Telegram Bot API.

You can run many session topics in parallel inside one group, and many groups in parallel across different projects.

Platforms: macOS, Windows, Linux

Fork sync notes: FORK_SYNC.md

OpenCode Telegram Group Topics Bot screencast

At a Glance

  • One Telegram group usually maps to one repo / project workspace.
  • The General topic is the control lane for /projects, /sessions, /new, and status checks.
  • Each new OpenCode session gets its own forum topic.
  • Each topic keeps its own session, model, agent, and pinned status state.
  • Optional TTS replies can be toggled globally with /tts and persist across restarts.
  • Subagent child-session work is summarized back into the parent topic as live status cards.
  • Multiple topics can run at the same time, and multiple groups can be active at the same time.
  • DMs are for light control/status usage, not the main multi-session workflow.

Quick Start

1. Prerequisites

2. Create and Prepare the Telegram Group

  1. Create a new Telegram supergroup for one OpenCode project/repository.
  2. Add your bot to that group.
  3. Make the bot an admin with permission to Manage Topics.
  4. Enable Topics in the group settings.
  5. In @BotFather, run /setprivacy for the bot and choose Disable.
  6. Keep the default General topic - that is the control lane.

3. Start OpenCode

Run OpenCode on the machine where the bot will live:

opencode serve

Default API URL: http://localhost:4096

4. Install the Bot

Option A: npx

npx opencode-telegram-group-topics-bot

Option B: Global install

npm install -g opencode-telegram-group-topics-bot
opencode-telegram-group-topics-bot config
opencode-telegram-group-topics-bot start

Option C: Run from source

git clone https://github.com/shanekunz/opencode-telegram-group-topics-bot.git
cd opencode-telegram-group-topics-bot
npm install
npm run build
node dist/cli.js config --mode sources
npm run dev

dist/cli.js is the compiled CLI entrypoint produced by npm run build.

5. Complete the Setup Wizard

The wizard asks for:

  • interface language
  • Telegram bot token
  • allowed Telegram user ID
  • OpenCode API URL
  • optional OpenCode server username/password

6. First-Time Verification

  1. Open a DM with your bot and run /start.
  2. Confirm the bot replies.
  3. Open your Telegram group and run /start in General.
  4. Run /status and confirm the bot can reach OpenCode.
  5. Run /projects in General and pick the repo for this group.
  6. Run /new in General to create a session topic.
  7. Open the new topic and send a prompt.

If that works, your group workspace is ready.

Daily Workflow

  1. Start OpenCode with opencode serve
  2. Start the bot
  3. Open the Telegram group and go to General
  4. Use /projects to confirm the selected repo
  5. Use /new to create a new session topic
  6. Work inside the topic thread
  7. Use /sessions in General to revisit older session lanes

Parallel Workloads and Telegram Rate Limits

  • This fork is designed for parallel work: many topic threads in one group, and many groups across projects.
  • Telegram enforces message rate limits, especially when many topics are receiving updates at once.
  • The bot handles those limits gracefully and slows or staggers Telegram updates when needed.
  • Your OpenCode sessions continue running even if Telegram updates become less frequent.
  • In heavy parallel usage, expect less real-time chatter per topic, but not lost OpenCode work.

Commands

CommandDescription
/statusServer health, current project, session, and model info
/newCreate a new session topic
/abortAbort the current task
/sessionsBrowse and switch between recent sessions
/projectsSwitch between OpenCode projects
/ttsToggle audio replies globally
/renameRename the current session
/commandsBrowse and run custom commands
/taskCreate a scheduled task for the current project
/tasklistList and delete scheduled tasks for the current project
/opencode_startStart the OpenCode server remotely
/opencode_stopStop the OpenCode server remotely
/helpShow available commands

Any normal text message in a session topic is treated as a prompt when no blocking interaction is active.

How This Fork Differs From Upstream

TopicUpstreamThis fork
Main UXOne chatOne group with forum topics
Session layoutSwitch sessions in one laneOne topic per session lane
Best forSimplicityParallel mobile workflows
ComplexityLowerHigher

If you want the simpler path, use the upstream project.

Configuration

Config Location

  • Source mode stores config in the repository root.
  • Installed mode stores config in the platform app-data directory.
  • OPENCODE_TELEGRAM_HOME overrides both and forces a custom config directory.

Installed-mode config paths:

  • macOS: ~/Library/Application Support/opencode-telegram-group-topics-bot/.env
  • Windows: %APPDATA%\opencode-telegram-group-topics-bot\.env
  • Linux: ~/.config/opencode-telegram-group-topics-bot/.env

Environment Variables

VariableDescriptionRequiredDefault
TELEGRAM_BOT_TOKENBot token from @BotFatherYes-
TELEGRAM_ALLOWED_USER_IDYour numeric Telegram user IDYes-
TELEGRAM_PROXY_URLProxy URL for Telegram API (SOCKS5/HTTP)No-
OPENCODE_API_URLOpenCode server URLNohttp://localhost:4096
OPENCODE_SERVER_USERNAMEServer auth usernameNoopencode
OPENCODE_SERVER_PASSWORDServer auth passwordNo-
OPENCODE_MODEL_PROVIDERDefault model providerYesopencode
OPENCODE_MODEL_IDDefault model IDYesbig-pickle
BOT_LOCALEBot UI language (en, de, es, fr, ru, zh)Noen
SESSIONS_LIST_LIMITSessions per page in /sessionsNo10
PROJECTS_LIST_LIMITProjects per page in /projectsNo10
COMMANDS_LIST_LIMITCommands per page in /commandsNo10
SCHEDULED_TASK_POLL_INTERVAL_SECScheduled task poll interval in secondsNo30
SERVICE_MESSAGES_INTERVAL_SECService messages interval; keep >=2 to avoid Telegram rate limits, 0 = immediateNo5
HIDE_THINKING_MESSAGESHide Thinking... service messagesNofalse
HIDE_TOOL_CALL_MESSAGESHide tool-call service messagesNofalse
MESSAGE_FORMAT_MODEAssistant reply formatting mode: markdown or rawNomarkdown
RESPONSE_STREAM_THROTTLE_MSDelay between streamed assistant updates in msNo1000
BASH_TOOL_DISPLAY_MAX_LENGTHMaximum displayed length for bash tool commands in Telegram summariesNo128
CODE_FILE_MAX_SIZE_KBMax file size (KB) to send as a documentNo100
STT_API_URLWhisper-compatible API base URLNo-
STT_API_KEYAPI key for your STT providerNo-
STT_MODELSTT model name passed to /audio/transcriptionsNowhisper-large-v3-turbo
STT_LANGUAGEOptional language hintNo-
TTS_API_URLTTS API base URLNo-
TTS_API_KEYTTS API keyNo-
TTS_MODELTTS model name passed to /audio/speechNogpt-4o-mini-tts
TTS_VOICEOpenAI-compatible TTS voice nameNoalloy
LOG_LEVELLog level (debug, info, warn, error)Noinfo

Keep your .env private. It contains your bot token.

Optional: Voice and Audio Transcription

If STT_API_URL and STT_API_KEY are set, the bot can transcribe Telegram voice/audio messages before sending them to OpenCode.

If TTS credentials are configured, you can toggle spoken replies globally with /tts. The preference is stored in settings.json and persists across restarts.

TTS configuration example:

TTS_API_URL=https://api.openai.com/v1
TTS_API_KEY=your-tts-api-key
TTS_MODEL=gpt-4o-mini-tts
TTS_VOICE=alloy

Whisper-compatible examples:

  • OpenAI: https://api.openai.com/v1
  • Groq: https://api.groq.com/openai/v1
  • Together: https://api.together.xyz/v1

Model Picker Notes

  • Favorites are shown before recent models
  • The current model is marked with
  • The default model from OPENCODE_MODEL_PROVIDER + OPENCODE_MODEL_ID is always included

To add favorites, open the OpenCode TUI and press Cmd+F / Ctrl+F on a model.

Features

  • Thread-scoped OpenCode sessions inside Telegram forum topics
  • Scheduled tasks with a dedicated per-project scheduled topic in forum groups
  • Pinned live status messages per topic
  • Live assistant response streaming and streamed tool-call updates
  • Model, agent, variant, and context controls from the keyboard
  • Custom OpenCode command execution
  • Interactive permission and question handling
  • Voice/audio transcription support
  • File attachments for images, PDFs, and text files
  • Strict single-user access control

Security

Only the Telegram user whose ID matches TELEGRAM_ALLOWED_USER_ID can use the bot.

Since the bot runs locally and connects to your local OpenCode server, there is no exposed public service beyond Telegram itself.

Development

Run from source

git clone https://github.com/shanekunz/opencode-telegram-group-topics-bot.git
cd opencode-telegram-group-topics-bot
npm install
npm run build
node dist/cli.js config --mode sources
npm run dev

Scripts

ScriptDescription
npm run devBuild and start
npm run buildCompile TypeScript
npm startRun compiled code
npm run release:notes:previewPreview release notes
npm run lintRun ESLint
npm run formatRun Prettier
npm testRun tests
npm run test:coverageRun tests with coverage

No watcher is used because the bot maintains persistent SSE and polling connections.

Troubleshooting

Bot does not respond

  • Confirm TELEGRAM_ALLOWED_USER_ID matches your real Telegram user ID
  • Confirm the bot token is correct
  • Make sure you disabled privacy mode in BotFather for group usage

OpenCode server is unavailable

  • Make sure opencode serve is running
  • Confirm OPENCODE_API_URL points to the correct address

Cannot create new session topics

  • Confirm the group is a supergroup with Topics enabled
  • Confirm the bot is an admin with Manage Topics permission
  • Run /new from General, not inside an existing session topic

No models appear in the picker

  • Add favorites in the OpenCode TUI
  • Confirm OPENCODE_MODEL_PROVIDER and OPENCODE_MODEL_ID are valid for your setup

Linux permission issues

  • Check the CLI binary is executable: chmod +x $(which opencode-telegram-group-topics-bot)
  • Check the config directory is writable: ~/.config/opencode-telegram-group-topics-bot/

Contributing

Please follow CONTRIBUTING.md.

Community

Open issues in this repository for this fork. For upstream discussion, see grinev/opencode-telegram-bot.

License

MIT • Original project © Ruslan Grinev • Fork changes © Shane Kunz