GPT ChatBot
About The Project
This repository represents GPT ChatBot in Telegram using OpenAI. With a focus on maintaining the context of dialog, this ChatBot offers intelligent responses and meaningful conversations. Alongside its conversational capabilities, the project incorporates advanced analytics and admin service. All the necessary data, including user conversations and statistics, are stored securely in a PostgreSQL Database.
Capabilities
- ChatGPT-3.5-Turbo
- Keeping the context of the converstaion
- Solid User Experience
- Admin service: adding and removing users, admins with commands
- Collecting user statistics via PostgreSQL Database
- Analytics for admins
Get Started
- Clone the repository:
git clone https://github.com/mayb333/GPT_ChatBot.git
- Install the required Python libraries:
pip install -r requirements.txt
- Specify the environment variables in
.env
file:
BOT_TOKEN = Bot Token
OPENAI_API_KEY = OpenAI API key
DATABASE_URL = PostgreSQL Database URL
CONTACT_ACCOUNT = Contact Account for getting access to the Bot
ADMIN_IDS_LIST = List of Adming IDs
ALLOWED_USERS_LIST = List of Allowed users IDs for using the Bot
- Start the Bot by running bash-script:
bash run_bot.sh
Project Structure
static/
: contains script to launch the Botsrc/
: contains application source folderapp/
:bot.py
: source code for the Botloader.py
: source code for initializating Bot, Dispatcher, Database
handlers/
:start.py
: source code for start handlerdialog.py
: source code for dialog handlersadmin.py
: source code for admin handlers
database/
:database.py
: source code for interaction with databasequeries
: sql queries for create tables in PostgreSQL
utils/
:openai_service.py
: source code for OpenAI serviceadmin_service.py
: source code for admin servicemessages.py
: source code for messages processingmarkups.py
: source code for keyboard markups