Telegram Bot Template for Vercel Serverless Functions
Just click the blue button and change something in src/bot.mjs in newly minted repository
Use webhooks or long polling locally, even without a Vercel project or CLI
Webhooks will be automatically installed for every deployment on Vercel during the build step
You can choose from one of the following two methods to use this repository:
Deploy the template using Vercel:
Select the appropriate option and deploy it to the cloud with Vercel
Please note that you will need to create a Vercel project and set the bot token in the settings
npm run polling
Using webhooks with CloudFlare tunnel (cloudflared
) :
npm run webhook
And open link from terminal (ends with *.trycloudflare.com
) to set webhooks URL
If you want another tunnel, just use
vercel dev
Set environment variable or create .env
file:
TELEGRAM_BOT_TOKEN="Telegram Bot Token from t.me/BotFather"
Run in long polling mode:
npm run start
💡 This command does not require a Vercel account or CLI installation to run
TELEGRAM_BOT_TOKEN
— Telegram bot token from @BotFatherTELEGRAM_SECRET_TOKEN
— Secret token for incoming requests
- src/bot.mjs — Bot initialization and logic
- scripts/start.mjs — Starts bot in long polling mode
- scripts/build.mjs — Sets webhook URL at build step
- api/webhook.mjs — Function for set webhook URL at dev
- api/update.mjs — Function for receiving updates
- For Vercel Edge Functions
- For Vercel Edge Functions with streaming response
- For Vercel Serverless Functions
Made with 💜 by Vladislav Ponomarev