TeleBot bootstrap for Vercel
npm install telebot-vercelA simple bootstrap for TeleBot that will help you quickly develop or migrate
your Telegram bot
to Vercel
> Both Serverless
> and Edge functions are supported !
Webhook receiver function:
``js
import TeleBot from "telebot"
import {start} from "telebot-vercel"
const bot = new TeleBot(/ TELEGRAM_BOT_TOKEN /)
bot.on('text', msg => msg.reply.text(msg.text))
export default start({bot}) // Instead of bot.start()
`
Webhook setup function:
`js
import TeleBot from "telebot"
import {setWebhook} from 'telebot-vercel'
const bot = new TeleBot(/ TELEGRAM_BOT_TOKEN /)
const path = 'api/webhook.mjs' // Receiver function path
export default setWebhook({bot, path}) // Instead of bot.setWebhook()
`
If you use plugins (including built-in ones), then you need to import them manually:
`js
import TeleBot from "telebot"
import "telebot/plugins/shortReply.js"
import "telebot/plugins/regExpMessage.js"
`
... or specify them in vercel.json:
`json``
{
"functions": {
"api/**": {
"includeFiles": "node_modules/telebot/plugins/**"
}
}
}
- Multiple environments
- Default hostname
- Error output
Made with 💜 by Vladislav Ponomarev