JSPM

telegraf

3.9.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 131590
  • Score
    100M100P100Q163426F
  • License MIT

📡 Modern Telegram bot framework

Package Exports

  • telegraf

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (telegraf) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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

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

Using yarn

$ yarn add telegraf

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.

Quick start

Step-by-step instructions for building and deploying basic bot with 🤖 micro-bot (Telegraf high level wrapper).

Documentation

Telegraf developer docs

Examples

const Telegraf = require('telegraf')

const app = new Telegraf(process.env.BOT_TOKEN)
app.command('start', ({ from, reply }) => {
  console.log('start', from)
  return reply('Welcome!')
})
app.hears('hi', (ctx) => ctx.reply('Hey there!'))
app.on('sticker', (ctx) => ctx.reply('👍'))
app.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.

Community bots