Telegram Service
The Telegram Service enables sending messages to Telegram chats via a Telegram Bot.
Usage
Initialization
Instantiate the TelegramService with your bot token.
import { TelegramService } from '@orbitus/core/services/telegram';
const telegramService = new TelegramService('telegram-bot', {
token: process.env.TELEGRAM_BOT_TOKEN
});Sending a Message
Send a message to a specific chat ID (user or group).
await telegramService.sendMessage({
chatId: '123456789',
text: 'System alert: High CPU usage detected.'
});Configuration
Environment Variables
| Variable | Description |
|---|---|
TELEGRAM_BOT_TOKEN | The API token for your Telegram Bot (obtained from @BotFather). |
Getting Chat ID
To find the Chat ID:
- Start a chat with your bot.
- Send a message.
- Call
https://api.telegram.org/bot<YOUR_TOKEN>/getUpdatesto see the chat ID in the JSON response.
Last updated on