{"library":"node-telegram-bot-api","title":"Node.js Telegram Bot API Client","description":"This package, `node-telegram-bot-api`, provides a comprehensive interface for interacting with the official Telegram Bot API in Node.js environments. It currently maintains version `0.67.0`, which includes robust support for Telegram Bot API up to v8.1, demonstrating an active release cadence closely aligned with new Telegram API features and ensuring compatibility. The library supports both long polling and webhook methods for receiving updates, offering flexibility for various deployment scenarios and scalability needs. Its primary differentiator is its direct and extensive mapping to the Telegram Bot API methods, providing a low-level yet convenient way to build Telegram bots. It offers robust event-driven handling for various message types and commands, along with utilities for sending messages, media, and managing chat interactions. It is a foundational choice for developers looking for a well-maintained, feature-rich, and community-supported Telegram bot development library in Node.js.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install node-telegram-bot-api"],"cli":null},"imports":["import TelegramBot from 'node-telegram-bot-api';","const TelegramBot = require('node-telegram-bot-api');","import type { Message } from 'node-telegram-bot-api';"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import TelegramBot from 'node-telegram-bot-api';\n\n// Replace with your Telegram bot token obtained from @BotFather\nconst token = process.env.TELEGRAM_BOT_TOKEN ?? 'YOUR_TELEGRAM_BOT_TOKEN';\n\nif (token === 'YOUR_TELEGRAM_BOT_TOKEN') {\n  console.warn('WARNING: Replace YOUR_TELEGRAM_BOT_TOKEN with your actual bot token from @BotFather. You should use environment variables in production.');\n}\n\n// Create a bot instance using 'polling' for updates (suitable for development)\nconst bot = new TelegramBot(token, { polling: true });\n\n// Matches \"/echo [whatever]\" and sends it back\nbot.onText(/\\/echo (.+)/, (msg, match) => {\n  const chatId = msg.chat.id;\n  const resp = match[1]; // The captured \"whatever\"\n  bot.sendMessage(chatId, resp);\n  console.log(`Echoed '${resp}' to chat ${chatId}`);\n});\n\n// Listen for any kind of message and acknowledge it\nbot.on('message', (msg) => {\n  const chatId = msg.chat.id;\n  bot.sendMessage(chatId, 'Received your message!');\n  console.log(`Received message from chat ${chatId}: ${msg.text}`);\n});\n\nconsole.log('Bot is running and listening for messages...');","lang":"typescript","description":"Initializes a Telegram bot with long polling for updates, then echoes any message sent to it and responds specifically to the `/echo` command, acknowledging all other messages.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}