l want sample telegram bot code with JavaScript
- User
l want sample telegram bot code with JavaScript
- Assistant
Sure, here's a sample Telegram bot code using JavaScript:
javascriptconst TelegramBot = require('node-telegram-bot-api'); const token = 'YOUR_TELEGRAM_BOT_TOKEN'; const bot = new TelegramBot(token, {polling: true}); bot.onText(/\/start/, (msg) => { const chatId = msg.chat.id; bot.sendMessage(chatId, 'Welcome to My Telegram Bot!'); }); bot.onText(/\/hello/, (msg) => { const chatId = msg.chat.id; bot.sendMessage(chatId, 'Hello, how can I help you?'); }); bot.onText(/\/echo (.+)/, (msg, match) => { const chatId = msg.chat.id; const echoMessage = match[1]; bot.sendMessage(chatId, echoMessage); });