- Clone this repository:
git clone https://github.com/yeralin/TelegramGPT.git
- Install the required dependencies (required python version >3.7):
pip install -r requirements.txt
- Get OpenAI API key (
OPENAI_API_KEY
) and a Telegram bot token (TELEGRAM_TOKEN
) - Create a .env file in the root directory of the project and add the following:
OPENAI_API_KEY=<your-openai-api-key>
TELEGRAM_TOKEN=<your-telegram-bot-token>
Make sure to replace and with your actual API key and token.
To start the bot, run: python bot.py
Once the bot is running, you can interact with it by sending messages to it on Telegram.
/system <system-message>
- Sets the system message. If no message is provided, returns the current system message.- All other messages will be interpreted as messages to the bot.
- Go to the OpenAI website (https://openai.com/) and click on the "Get started for free" button.
- Create an account by filling out the registration form.
- Once you've created an account, you'll need to add a payment method to your account to get access to the API.
- Once you have added a payment method, go to the "API Keys" tab in your OpenAI account dashboard.
- Click on the "Create API Key" button and give your key a name.
- Copy the API key that is generated and store it somewhere safe.
- Store the API key under
.env
file asOPENAI_API_KEY=<your-openai-api-key>
OpenAI offers a free trial with $200 in credits, so you won't be charged if you stay within that limit.
- Open the Telegram app and search for the BotFather bot.
- Start a chat with the BotFather and type
/newbot
to create a new bot. - Follow the instructions from BotFather to provide a name and username for your bot.
- Once you have successfully created the bot, BotFather will provide you with a token.
- Store the token under
.env
file asTELEGRAM_TOKEN=<your-telegram-bot-token>
This project is licensed under the MIT License - see the LICENSE file for details.