Deploy this function on flows.network, and you will get a Telegram bot that uses ChatGPT to respond to every question in your Telegram DM or channel/group automatically.
The example in the above image is to leverage ChatGPT to generate code comments.
-
You will need to bring your own OpenAI API key. If you do not already have one, sign up here.
-
You also need a bot token to access the Telegram API. If you don't already have one, go to Telegram to get a bot token from @botfather.
To install the ChatGPT Telegram App, we will use flows.network, a serverless platform that makes deploying your own app quick and easy in just three steps.
Fork this repo and go to flows.network to deploy your function.
-
Log into flows.network from your GitHub account. It's free.
-
Click on the "Create a Flow" button to start deploying the ChatGPT GitHub APP
-
Authenticate the flows.network to access the
telegram-gpt
repo you just forked. -
Click the Advanced test to see more settings. Here we need to use Environment Variables to pass the Telegram token and OpenAI API key name.
telegram_token
: Fill in the token you received from Fatherbot.openai_key_name
: Fill in the name you want for your OpenAI key. You can put any name here, and we will connect it to the actual key later.
- Click on the Deploy button to deploy your function.
After that, the flows.network will direct you to configure the SaaS integration required by your flow. Since we have configured Telegram in the above step, OpenAI is the only SaaS we need to configure here.
Click the "Connect/+ Add new authentication" button to add your OpenAI API key. On the next page, copy and paste your OpenAI API key and then name the key. Note the name you enter here should be the same as the name in the environment variable.
Click on the Check button to see your flow details. As soon as the flow function's status becomes ready
and the flow's status becomes running
, the Telegram ChatGPT App goes live. Go ahead and send a private message to the bot! You can also invite this bot to your channel/group.
If you want to build locally, make sure you have installed Rust and added the wasm32-wasi
target.
cargo build --target wasm32-wasi --release