Version 1.0.1 is now available! Looking for a migration guide?
v1.0.1
/
  • Get Started
  • Working
  • GitHub
  • Overview
  • Introduction
  • Actions
  • Call
  • Call
  • CallList
  • CallList
  • FetchList
  • FetchList
  • Batch
  • Batch
  • BatchByChunk
  • BatchByChunk
  • Tools
  • HealthCheck
  • Ping
  • Logger
  • Logger
  • Telegram
  • Limiters
  • Limiters
  • B24Frame
  • Introduction
  • Initialization
  • Auth
  • Dialog
  • Options
  • Parent
  • Placement
  • Slider
  • b24ui
  • b24icons
v1.0.1
  • Get started
  • Working

Telegram Handler

Sending logs to Telegram
TelegramHandler
TelegramFormatter
We are still updating this page. Some data may be missing here — we will complete it shortly.

Quick Start

Installing and setting up a Telegram bot

# Create a bot via @BotFather
# Get the token and chat_id

Usage on the server side

import { LogLevel, Logger, TelegramHandler } from '@bitrix24/b24jssdk'

// Create a logger with Telegram handler
const $logger = new Logger('my-app')

const telegramHandler = new TelegramHandler(LogLevel.ERROR, {
  botToken: 'YOUR_BOT_TOKEN',
  chatId: 'YOUR_CHAT_ID',
  parseMode: 'HTML', // or 'MarkdownV2'
  disableNotification: false, // Send notifications
  disableWebPagePreview: true // Disable link previews
});

$logger.pushHandler(telegramHandler)

// Now critical errors will be sent to Telegram
$logger.error('Payment service unavailable', {
  service: 'stripe',
  error: 'Connection timeout',
  duration: '30s'
})

Usage on the client side

On the client side, it is not supported due to security requirements.

Logger

Logger inspired by PHP Monolog, provides a structured logging system with support for channels, handlers, processors, and formatters. Implementation follows PSR-3 principles and the chain of responsibility pattern.

Limiters

The restrictions system provides a comprehensive mechanism for managing request frequency, operation execution time, and adaptive delays.

On this page

  • Quick Start
    • Installing and setting up a Telegram bot
    • Usage on the server side
    • Usage on the client side
Releases
Published under MIT License.

Copyright © 2024-present Bitrix24