Skip to content

waptik/telegram-bot-boilerplate-now-serverless-api

Repository files navigation

Telegram Bot Boilerplate with Vercel's Serverless Functions

This template is a fork of Telegram Bot Boilerplate framework to be used with Vercel's Serverless Functions. Easily deploy to Vercel.

Deploy your own

The easiest way to get started is deploy using this template by clicking on the Deploy button below.

Deploy with Vercel

Alternatively, if you want to make some changes before deploying it, you can fork this template and do the necessary changes you need. Then you when are done with your changes simply goto vercel git import.

Notes

  • When importing a new project on vercel, you'll be asked to set the output directory. Set it to dist or the value inside tsconfig.js
  • You also need to set Environment variables. Please note the wording in brackets mentioned below. Also here is a list of environment variables you need to set:
  • BOT_TOKEN: Its value should be the token you received from BitFather when creating your bot. (secret)
  • VERCEL_URL: set to the system populated value seen in the dropdown when you choose the system variables option. (system)

Local development

Step 1. Clone the project locally

You can clone this template directly or the forked version you have.

git clone https://github.com/waptik/telegram-bot-boilerplate-now-serverless-api.git

# or

git clone https://github.com/<YOUR_GITHUB_USERNAME>/telegram-bot-boilerplate-now-serverless-api.git

Next, navigate to the cloned directory.

cd telegram-bot-boilerplate-now-serverless-api

Step 2. Configuration

Copy the .env.example file in this directory to .env (which will be ignored by Git):

cp .env.example .env

Next, copy your bot token you got from BotFather and and open .env to do the following changes.

BOT_TOKEN="<YOUR_BOT_TOKEN>"

Note: We are not using VERCEL_URL here because we are in development mode as it's not needed.

Step 3. Run the bot in development mode

Make sure you have Vercel CLI installed on your local machine.

npm install
npm run dev

# or

yarn install
yarn dev

Your app should be up and running! Send a message to your bot on telgram and you'll receive a reply instantly!

Step 4. Deploy on Vercel

After you are done, simply do the the following. If you cloned this template directly on your machine, you need set the origin. Read more on how to do that Add a remote.

After you are done or if you cloned the forked version, simply push to GitHub

git push

Demo

You can see a working version of the bot at @VercelServerlessFunctionsBot

Pull Requests are welcomed 😉