📡 Modern Telegram bot framework


Keywords
telegraf, telegram, telegram bot api, bot, botapi, bot framework, bot-framework, telegram-bot
License
MIT
Install
npm install telegraf@3.17.3

Contributors

Vitaly Domnikov Greenkeeper Denis Efremov Oleg Oskolsky Masoud Ghorbani Fiblan Leandro Späth Alexander Tomas Della Vedova verget runegan denisx Sergey Martynov Dmitriy Fabio Crispino Pouria Ezzati Bestulo Sabato Luca Guadagno firguy Michael SMAZNet Amirali Esmaeili Alex Saft Pria Purnama


See all contributors


Documentation

telegraf.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.

Telegraf Bot API Version NPM Version node bitHound Build Status js-standard-style

Features

Installation

$ npm install telegraf

or using yarn:

$ yarn add telegraf

Examples

const Telegraf = require('telegraf')

const bot = new Telegraf(process.env.BOT_TOKEN)
bot.start((ctx) => {
  console.log('started:', ctx.from.id)
  return ctx.reply('Welcome!')
})
bot.command('help', (ctx) => ctx.reply('Try send a sticker!'))
bot.hears('hi', (ctx) => ctx.reply('Hey there!'))
bot.hears(/buy/i, (ctx) => ctx.reply('Buy-buy!'))
bot.on('sticker', (ctx) => ctx.reply('👍'))

bot.startPolling()
const Telegraf = require('telegraf')
const { reply } = Telegraf

const bot = new Telegraf(process.env.BOT_TOKEN)
bot.command('/oldschool', (ctx) => ctx.reply('Hello'))
bot.command('/modern', ({ reply }) => reply('Yo'))
bot.command('/hipster', reply('λ'))
bot.startPolling()

There's some cool examples too.

Documentation

Telegraf developer docs