A bridge that connects messaging platforms (Telegram) to OpenCode, allowing you to interact with an AI coding assistant from anywhere.
- Telegram Integration - Chat with OpenCode directly from Telegram
- Session Management - Automatic session creation per chat
- Slash Commands - Full suite of OpenCode commands accessible via Telegram
- Streaming Responses - Real-time AI responses with tool call indicators
- Provider Management - Connect and switch between AI providers
# Install dependencies
bun install
# Copy environment template
cp .env.example .envEdit .env with your tokens:
# Telegram Bot Token (get from @BotFather)
TELEGRAM_BOT_TOKEN=your-telegram-bot-token-here
# OpenCode Working Directory (optional, defaults to current directory)
OPENCODE_DIR=/path/to/your/project
# OpenCode Server Port (optional, defaults to 4096)
OPENCODE_PORT=4096# Development mode (with hot reload)
bun run dev
# Production mode
bun run startForkBridge will automatically start the OpenCode server if not already running.
Send these commands to your Telegram bot:
| Command | Description |
|---|---|
/help |
Show all available commands |
/new |
Start a fresh session |
| Command | Description |
|---|---|
/models |
List available AI models |
/providers |
Show configured providers |
/sessions |
List all sessions |
/themes |
List available themes |
| Command | Description |
|---|---|
/model <id> |
Switch to a different model |
/provider <name> |
Switch provider |
/connect <provider> <key> |
Connect a provider (e.g. /connect openai sk-xxx) |
/init |
Initialize project (creates AGENTS.md) |
/share |
Share current session as a link |
/compact |
Compact/summarize session context |
/undo |
Undo last change |
/redo |
Redo last undone change |
Any other /command is forwarded directly to OpenCode.
┌─────────────┐ ┌──────────────┐ ┌─────────────┐
│ Telegram │ ──► │ ForkBridge │ ──► │ OpenCode │
│ Bot │ │ Agent │ │ Server │
└─────────────┘ └──────────────┘ └─────────────┘
- ForkBridge - Stateless bridge that routes messages between Telegram and OpenCode
- OpenCode - AI coding assistant running in serve mode
- Sessions - Named by
{channel}-{chatId}(e.g.,telegram-123456789)
src/
├── index.ts # Entry point
├── bridge.ts # Core routing logic
├── config.ts # Environment configuration
├── types.ts # TypeScript interfaces
├── channels/
│ ├── telegram.ts # Telegram adapter
│ └── stream-buffer.ts # Message throttling
└── opencode/
├── client.ts # HTTP client for OpenCode API
├── serve.ts # OpenCode server management
└── cli.ts # CLI fallback mode
# Type checking
bun run typecheck
# Build (if adding compilation step)MIT