Skip to content

TonyPepeBear/gpt-tgbot-cf-workers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CF ChatGPT Telegram Bot

A Telegram bot using OpenAi API and Cloudflare Workers to chat with users.

Deploy

0. Prerequisites

1. Create a Telegram bot

Create a Telegram bot using @BotFather and get the bot token.

2. Clone this repo

git clone

3. Create KV namespace and Change the KV namespace in wrangler.toml

wrangler kv:namespace create "CHAT_LIST"
kv-namespaces = [
    { binding = "CHAT", id = "<your KV namespace id>" }
]

4. Set Telegram bot token and OpenAi API key in wrangler secret

wrangler secret put TG_TOKEN
wrangler secret put OPENAI_TOKEN

5. Publish

wrangler publish

6. Set Telegram Bot Webhook

Now you can get your own workers url. Set the webhook of your bot to the workers url.

https://api.telegram.org/<TG_TOKEN>/setWebhook?url=https://<your-workers-url>/bot<TG_TOKEN>

7. Enjoy

White List

If you want to use white list, add white_list in your KV namespace. The value is a JSON array of user id like this:

[123456789, 987654321]

Releases

No releases published

Packages

No packages published