| name | add-telegram |
| command | /add-telegram |
| description | Add Telegram as a communication channel |
| requiredEnvVars | ["TELEGRAM_BOT_TOKEN"] |
| requiredTools | ["write_file","read_file","run_code","install_pkg"] |
| platforms | ["linux","macos","windows"] |
| version | 1.0.0 |
| author | betaclaw |
betaclaw Add Telegram Skill
You are the Telegram integration assistant. Set up a Telegram bot as a communication channel for betaclaw.
Step 1: Bot Creation
If the user doesn't already have a bot token:
- Direct them to message @BotFather on Telegram.
- Send
/newbot and follow the prompts to create a bot.
- Copy the bot token (format:
123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11).
Step 2: Collect Token
- Prompt the user for their
TELEGRAM_BOT_TOKEN.
- Validate the token format: should match
^\d+:[A-Za-z0-9_-]{35,}$.
- Store the token in the encrypted vault. Never write to
.env or logs.
Step 3: Install Dependencies
Run: npm install node-telegram-bot-api
Run: npm install -D @types/node-telegram-bot-api (if not already present)
Step 4: Create Channel Adapter
Create src/channels/telegram.ts implementing the IChannel interface:
import TelegramBot from 'node-telegram-bot-api';
import type { IChannel, InboundMessage, OutboundMessage, ChannelFeature } from './interface.js';
class TelegramChannel implements IChannel {
id = 'telegram';
name = 'Telegram';
private bot: TelegramBot;
private messageHandler: ((msg: InboundMessage) => void) | null = null;
constructor(token: string) {
this.bot = new TelegramBot(token, { polling: true });
}
async connect(): Promise<void> {
this.bot.on('message', (msg) => {
if (!this.messageHandler || !msg.) ;
.({
: msg..(),
: msg...(),
: msg.?..() ?? ,
: msg.,
: msg. * ,
: msg.?..(),
});
});
}
(): <> {
..();
}
(: ): <> {
..(msg., msg., {
: msg. ? (msg.) : ,
: ,
});
}
(: ): {
. = handler;
}
(: ): {
: [] = [, , , ];
supported.(f);
}
}
Adapt the above to match the project's exact interface and coding conventions.
Step 5: Register Channel
- Add
telegram to the enabled channels list in .beta/config.toon.
- Register the channel with the orchestrator so it receives inbound messages and can send outbound messages.
Step 6: Configure Bot Settings (Optional)
Ask the user if they want to configure:
- Trigger word: Whether the bot responds to all messages or only when mentioned (default: respond to all in private chats, trigger word in groups).
- Allowed groups/chats: Restrict to specific chat IDs for security.
- Bot commands: Register slash commands with BotFather (
/setcommands).
Step 7: Test Connection
- Call
getMe() on the Telegram Bot API to verify the token works.
- Display the bot's username to the user.
- Ask the user to send a test message to the bot on Telegram.
- Verify the message is received by betaclaw and a response is sent back.
Step 8: Confirm
Report to the user:
- Telegram bot
@{botUsername} is now connected
- The bot is listening for messages
- Private messages are processed directly; group messages require the trigger word
- Bot token is stored securely in the vault
- To stop: remove
telegram from enabled channels in /customize