# Cloudflare Workers Deployment Guide > If you need local deployment or Docker deployment, please refer to the [Local Deployment](LOCAL.md) documentation. > > If you need to deploy to Vercel, please check the [Vercel deployment example](VERCEL.md) documentation. ## Video tutorial image Thank [**科技小白堂**](https://www.youtube.com/@lipeng0820) for providing this video tutorial. ## Manual deployment ### 1. Create a new Telegram bot, obtain the Token. image 1. Open Telegram and send the `/start` command to BotFather. 2. Send the `/newbot` command and give your bot a name. 3. Give your bot a unique username ending with `_bot`. 4. 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! 5. Later, in the Cloudflare Workers settings, fill this Token into the `TELEGRAM_AVAILABLE_TOKENS` variable. 6. If you need to support group chats or set up other Telegram Bot APIs, please refer to the [configuration documentation](CONFIG.md) to set the corresponding variables. ### 2. Register an OpenAI account and create an API Key. image 1. Open [OpenAI](https://platform.openai.com) to register an account. 2. Click on the avatar in the upper right corner to enter the personal settings page. 3. Click on API Keys to create a new API Key. 4. Later, in the Cloudflare Workers settings, fill this Token into the `OPENAI_API_KEY` variable. 5. If you are using third-party AI services, please refer to the [configuration document](CONFIG.md) to set the corresponding variables. ### 3. Deploy Workers image 1. Open [Cloudflare Workers](https://dash.cloudflare.com/?to=/:account/workers) and register an account. 2. Click on `Create a Service` in the upper right corner. 3. Enter the newly created workers, select `Quick Edit`, copy the code from [`../dist/index.js`](../../dist/index.js) into the editor, and save. ### 4. Configure environment variables image 1. Open [Cloudflare Workers](https://dash.cloudflare.com/?to=/:account/workers), click on your Workers, then click on the top right corner's Setting -> Variables. 2. Check the [configuration document](CONFIG.md) for the required environment variables that must be filled in. ### 5. Bind KVNamespace 1. In `Home-Workers-KV`, click on the `Create a Namespace` in the upper right corner, name it whatever you like, but it must be set to `DATABASE` when binding.
image 2. Open [Cloudflare Workers](https://dash.cloudflare.com/?to=/:account/workers) and click on your Workers. 3. Click in the upper right corner Setting -> Variables
image 4. In `KV Namespace Bindings`, click `Edit variables`. 5. Click `Add variable`. 6. Set the name to `DATABASE` and select the KV data you just created. ### 6. Initialization 1. Run `https://workers_name.username.workers.dev/init` to automatically bind the Telegram webhook and set all commands. ### 七. Start chatting image 1. Start a new conversation by using the `/new` command, and thereafter, the chat context will be sent to ChatGPT each time. 2. If you want to learn how to use other commands, please refer to the [configuration document](CONFIG.md). ## Command Line Deployment 1. Prepare the required Telegram Bot Token and OpenAI API Key 2. `mv wrangler-example.toml wrangler.toml`, then modify the corresponding configuration 3. `pnpm install` 4. `pnpm run deploy:dist`