This feature sends Telegram messages via the Bot API when OpenCode session events occur, such as when a session becomes idle or encounters an error.
- Open Telegram and search for @BotFather
- Send
/newbotand follow the prompts to create a bot - BotFather will give you a Bot Token (e.g.,
123456789:ABCdefGhIjKlMnOpQrStUvWxYz)
- Start a conversation with your new bot (search for it by username and press Start)
- Send any message to the bot
- Open this URL in your browser (replace
YOUR_BOT_TOKEN):https://api.telegram.org/botYOUR_BOT_TOKEN/getUpdates - Look for
"chat":{"id":123456789}in the response — that number is your Chat ID
Tip: For group chats, add the bot to the group, send a message, and check
getUpdates. Group chat IDs are typically negative numbers.
Set the following environment variables:
# Required - Your bot token from @BotFather
export TELEGRAM_BOT_TOKEN=123456789:ABCdefGhIjKlMnOpQrStUvWxYz
# Required - The chat ID to send messages to
export TELEGRAM_CHAT_ID=987654321Opencode will automatically detect these when you start a new session and send you notifications when tasks are complete.