If you need local deployment or Docker deployment, please refer to the Local Deployment documentation.
If you need to deploy to Vercel, please check the Vercel deployment example documentation.
Thank 科技小白堂 for providing this video tutorial.
- Open Telegram and send the
/start
command to BotFather. - Send the
/newbot
command and give your bot a name. - Give your bot a unique username ending with
_bot
. - BotFather will generate a Token; copy it and save it. This Token is the key linked to your bot, do not disclose it to others!
- Later, in the Cloudflare Workers settings, fill this Token into the
TELEGRAM_AVAILABLE_TOKENS
variable. - If you need to support group chats or set up other Telegram Bot APIs, please refer to the configuration documentation to set the corresponding variables.
- Open OpenAI to register an account.
- Click on the avatar in the upper right corner to enter the personal settings page.
- Click on API Keys to create a new API Key.
- Later, in the Cloudflare Workers settings, fill this Token into the
OPENAI_API_KEY
variable. - If you are using third-party AI services, please refer to the configuration document to set the corresponding variables.
- Open Cloudflare Workers and register an account.
- Click on
Create a Service
in the upper right corner. - Enter the newly created workers, select
Quick Edit
, copy the code from../dist/index.js
into the editor, and save.
- Open Cloudflare Workers, click on your Workers, then click on the top right corner's Setting -> Variables.
- Check the configuration document for the required environment variables that must be filled in.
- In
Home-Workers-KV
, click on theCreate a Namespace
in the upper right corner, name it whatever you like, but it must be set toDATABASE
when binding. - Open Cloudflare Workers and click on your Workers.
- Click in the upper right corner Setting -> Variables
- In
KV Namespace Bindings
, clickEdit variables
. - Click
Add variable
. - Set the name to
DATABASE
and select the KV data you just created.
- Run
https://workers_name.username.workers.dev/init
to automatically bind the Telegram webhook and set all commands.
- Start a new conversation by using the
/new
command, and thereafter, the chat context will be sent to ChatGPT each time. - If you want to learn how to use other commands, please refer to the configuration document.
- Prepare the required Telegram Bot Token and OpenAI API Key
mv wrangler-example.toml wrangler.toml
, then modify the corresponding configurationpnpm install
pnpm run deploy:dist