Create your own Telegram bot in minutes with the official Bot API!
An echo bot in 9 lines: (CoffeeScript)
Telegram=require'telegram-bot'tg=newTelegram(process.env.TELEGRAM_BOT_TOKEN)
tg.on'message', (msg) ->returnunlessmsg.texttg.sendMessagetext:msg.textreply_to_message_id:msg.message_idchat_id:msg.chat.idtg.start()or 11 lines (JavaScript):
varTelegram=require('telegram-bot');vartg=newTelegram(process.env.TELEGRAM_BOT_TOKEN);tg.on('message',function(msg){if(!msg.text)return;tg.sendMessage({text: msg.text,reply_to_message_id: msg.message_id,chat_id: msg.chat.id});});tg.start();For more examples, checkout the examples folder!
All methods in the official Bot API can be called directly on the Telegram object. For a complete list of available methods, check it out here.
- better logging
- add more examples utilizing multimedia messages