This template is a fork of Telegram Bot Boilerplate framework to be used with Vercel's Serverless Functions. Easily deploy to Vercel.
The easiest way to get started is deploy using this template by clicking on the Deploy button below.
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.
- 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)
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
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.
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!
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
You can see a working version of the bot at @VercelServerlessFunctionsBot
Pull Requests are welcomed 😉