telebot-vercel

1.0.1 • Public • Published

TeleBot bootstrap for Vercel

A simple bootstrap for TeleBot that will help you quickly develop or migrate your Telegram bot to Vercel

Both Serverless and Edge functions are supported !

How to use

Webhook receiver function:

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:

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:

import TeleBot from "telebot"

import "telebot/plugins/shortReply.js"
import "telebot/plugins/regExpMessage.js"

... or specify them in vercel.json:

{
  "functions": {
    "api/**": {
      "includeFiles": "node_modules/telebot/plugins/**"
    }
  }
}

Complete usage example

You can also use additional options:

  • Multiple environments
  • Default hostname
  • Error output

Made with 💜 by Vladislav Ponomarev

Package Sidebar

Install

npm i telebot-vercel

Weekly Downloads

1,304

Version

1.0.1

License

MIT

Unpacked Size

10.2 kB

Total Files

10

Last publish

Collaborators

  • ponomarevlad