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.
- Full Telegram Bot API 3.4 support
- Telegram Payment Platform
- HTML5 Games
- Inline mode
- Incredibly fast
- AWS 位/now/Heroku/Firebase/Glitch ready
http
/https
/Connect.js
/express.js
compatible webhooks- Easy to extend
$ npm install telegraf --save
Using yarn
$ yarn add telegraf
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
.
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.
Step-by-step instructions for building and deploying basic bot with 馃 micro-bot (Telegraf high level wrapper).
- yt-search-bot
- scrobblerBot
- Counter Bot
- GNU/Linux Indonesia Bot
- The Guard Bot
- Chat Linker Bot
- Send PR to add link to your bot