/telegraf

📡 Modern Telegram bot framework

Primary LanguageJavaScriptMIT LicenseMIT

NPM Version node bitHound Build Status js-standard-style

Telegraf

📡 Modern Telegram bot framework for Node.js

Bots are special Telegram accounts designed to handle messages automatically. Users can interact with bots by sending them command messages in private or group chats. These accounts serve as an interface for code running somewhere on your server.

Features

Installation

$ npm install telegraf --save

Telegram token

To use the Telegram Bot API, you first have to get a bot account by chatting with BotFather.

BotFather will give you a token, something like 123456789:AbCdfGhIJKlmNoQQRsTUVwxyZ. With the token in hand, you can start developing your bot.

Example

const Telegraf = require('telegraf')

const app = new Telegraf(process.env.BOT_TOKEN)

app.command('start', (ctx) => {
  console.log('start', ctx.from)
  ctx.reply('Welcome!')
})

app.hears('hi', (ctx) => ctx.reply('Hey there!'))
app.on('sticker', (ctx) => ctx.reply('👍'))

app.startPolling()

There's some cool examples.

Documentation

Telegraf developer docs