-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
182cb88
commit 784af43
Showing
1 changed file
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Telegram bot powered by OpenAI assistant API | ||
|
||
## Usage | ||
|
||
https://t.me/bubby2023_bot | ||
|
||
## Deployment | ||
|
||
```shell | ||
# this project uses PNPM instead of NPM | ||
npm install --global pnpm | ||
|
||
# install dependencies | ||
pnpm install | ||
|
||
# set secrets for the local stage | ||
## create new secret key at https://platform.openai.com/api-keys | ||
pnpm sst secrets set OPENAI_API_KEY sk-xxx | ||
## create new assistant at https://platform.openai.com/assistants | ||
pnpm sst secrets set OPENAI_ASSISTANT_ID asst_xxx | ||
## chat with https://t.me/BotFather to create a new bot | ||
pnpm sst secrets set TELEGRAM_BOT_TOKEN '123:xxx' | ||
## use https://www.random.org/passwords/ or similar tool to generate a random password | ||
pnpm sst secrets set TELEGRAM_WEBHOOK_SECRET_TOKEN s3cret | ||
|
||
# this project use SST to deploy to AWS | ||
# use its dev command for https://docs.sst.dev/live-lambda-development | ||
pnpm dev | ||
|
||
# register webhook | ||
curl https://api.telegram.org/bot${TELEGRAM_BOT_TOKEN}/setWebhook \ | ||
-F url=https://xxx.execute-api.us-east-1.amazonaws.com/api/webhook \ | ||
-F secret_token=${TELEGRAM_WEBHOOK_SECRET_TOKEN} | ||
|
||
# check webhook status | ||
curl https://api.telegram.org/bot${TELEGRAM_BOT_TOKEN}/getWebhookInfo | ||
``` |