Telegram bot enabling voice journaling.
Forked from @jxnl's repo, jxnl/vercel-telegram-gpt.
- Clone this repository
- Create a
.env
file and add your Telegram bot token OpenAI API key - Optionally you can also add a OpenAI API key to enable the
/gpt
command - Create a virtual environment by running
python3 -m venv env
- Activate the virtual environment by running
source env/bin/activate
- Install the required packages by running
pip install -r requirements.txt
- Visit the telebot docs to get a rundown on how to make more complex responses.
- Connect your GitHub repository to Vercel or
- Run
npm i -g vercel
to install vercel - Run
vercel auth
to authenticate - Run
vercel
the first time to set up the itegrationto deploy the app - Run
vercel dev
to test the application locally - Run
vercel secrets add [secret-name] [secret-value]
to set your tokens - Run
vercel deploy
to deploy the application as a preview
- Run the
app.py
script use the URL of your Vercel-deployed app as the webhook URL
- In the
app.py
file, import the OpenAI package and Telebot package - Implement the function for calling the GPT-3 API and generating a response
- In the Telegram bot handling function, call the GPT-3 function and use the generated response as the bot's reply using telebot
Congratulations, you have successfully created and deployed a Telegram bot using Flask, Webhooks, and Vercel. You have also added the functionality of GPT-3 to generate responses for your bot using Telebot.
Feel free to reach out if you have any questions or issues. Happy coding!