Skip to content

medo-ma/tbotseverless

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

telegram-bot-vercel-serverless-template

TW

Here is a simple Telegram bot template specifically designed for beginners

Click on the Use this template button in the upper right or click here will immediately add this template to your own GitHub repository.Alternatively, you can click on the button Deploy with Vercel to directly deploy it to Vercel.

The content on this page has been translated using ChatGPT

Table of contents

One Click Deployment

Deploy with Vercel

Essential Content

Before using this template, it is important to have a basic understanding of the following content.

Local Development

Clone Project

Click on the Use this template button in the upper right or click here will immediately add this template to your own GitHub repository.

Set Environment Variable

Create a .env file in the root directory and add the following content.

TELEGRAM_BOT_TOKEN=<TELEGRAM_BOT_TOKEN>

Set the provided TOKEN from Telegram Bot.

Obtain External Domain

Enter the following content in the terminal.

vercel dev

> Vercel CLI 30.0.0
> Ready! Available at http://localhost:3000

Open ngrok to obtain a publicly accessible URL, then enter the following content in another terminal.

ngrok http 3000

Set Webhook

Finally, set up the webhook and copy the following URL

https://api.telegram.org/bot<TELEGRAM_BOT_TOKEN>/setWebhook?url=<Webhook_URL>

Replace the content with your own TOKEN and webhook URL.

  • TELEGRAM_BOT_TOKEN
  • Webhook_URL

Note that when setting the webhook URL, it should be DOMAIN name + '/api/webhook' to correspond to the path of the webhook. Once you have made the necessary modifications to the above content, open a blank page in your browser and paste it to submit.

Deployment

Deploy with Vercel CLI

Enter the following content in the terminal.

vercel

It will be automatically deployed to Vercel.

Environment Variable

Go to Vercel DashboardDashboard – Vercel

After locating the recently deployed project, configure the environment variables.

Set your own bot token inside.

KEY VALUE
TELEGRAM_BOT_TOKEN <TELEGRAM_BOT_TOKEN>

Webhook

After completing the deployment, you will obtain a URL provided by Vercel. Simply reconfigure the webhook.

https://api.telegram.org/bot<TELEGRAM_BOT_TOKEN>/setWebhook?url=<Webhook_URL>

<TELEGRAM_BOT_TOKEN> corresponds to the bot's TOKEN, and <Webhook_URL> corresponds to the Vercel URL + '/api/webhook'. Once you have made the necessary modifications to the above content, open a blank page in your browser, paste it, and submit.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published