All Projects → oott123 → node-telegram-bot

oott123 / node-telegram-bot

Licence: MIT license
Create your own Telegram bot in minutes with the official Bot API

Programming Languages

coffeescript
4710 projects
javascript
184084 projects - #8 most used programming language
Makefile
30231 projects

telegram-bot

npm version

Create your own Telegram bot in minutes with the official Bot API!

Quick Start

An echo bot in 9 lines: (CoffeeScript)

Telegram = require 'telegram-bot'

tg = new Telegram(process.env.TELEGRAM_BOT_TOKEN)
tg.on 'message', (msg) ->
  return unless msg.text
  tg.sendMessage
    text: msg.text
    reply_to_message_id: msg.message_id
    chat_id: msg.chat.id

tg.start()

or 11 lines (JavaScript):

var Telegram = require('telegram-bot');
var tg = new Telegram(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!

API Reference

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.

Todo

  • better logging
  • add more examples utilizing multimedia messages
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].