Skip to Content
ServicesTelegram Service

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

VariableDescription
TELEGRAM_BOT_TOKENThe API token for your Telegram Bot (obtained from @BotFather).

Getting Chat ID

To find the Chat ID:

  1. Start a chat with your bot.
  2. Send a message.
  3. Call https://api.telegram.org/bot<YOUR_TOKEN>/getUpdates to see the chat ID in the JSON response.
Last updated on