Skip to content

renatomh/chatgpt-telegram-bot

Repository files navigation

ChatGPT Telegram Bot

ChatGPT Telegram Bot

💡 Project's Idea

This project was developed to provide a personal Telegram Chatbot that allows communication with OpenAI's ChatGPT API. It aims to be deployed with AWS Lambda functions, in order to make it scalable.

Access it live on Telegram (only available for the admin, in order to avoid API costs to the owner. You can create your own, using this code as base)

🔍 Features

  • Ask ChatGPT specific questions;
  • Have context based conversations with ChatGPT;

sample

  • Generate images from prompts with DALL-E 3;

sample image generation

  • Provide images for chat contexts;

sample image chat

🛠 Technologies

During the development of this project, the following techologies were used:

💻 Project Configuration

First, create a new virtual environment on the root directory

$ python -m venv env

Activate the created virtual environment

$ .\env\Scripts\activate # On Windows machines
$ source ./env/bin/activate # On MacOS/Unix machines

Install the required packages/libs

(env) $ pip install -r requirements.txt

🌐 Setting up config files

Create an .env file on the root directory, with all needed variables, credentials and API keys, according to the sample provided (example.env).

⏯️ Running

To run the project in a development environment, execute the following command on the root directory, with the virtual environment activated.

(env) $ python bot.py

In order to leave the virtual environment, you can simply execute the command below:

(env) $ deactivate

👀 Observations

If you want to deploy the bot with AWS Lambda functions, the code file will be the lambda function file.

For that, there are some extra steps to be done, such as:

  1. Creating the AWS Lambda function;
  2. Setting the function trigger as an Amazon API Gateway;
  3. Setting the webhook for the Telegram communication with the API Gateway route;
  4. Creating the DynamoDB file with the messages list;
  5. Adjusting the AWS Lambda function role to allow accessing the DynamoDB tables;
  6. Setting up environment variables on the configurations for the Lambda function;
  7. Adding the external Python libraries to Lambda function using layers;

Documentation:

📄 License

This project is under the MIT license. For more information, access LICENSE.

About

A Python Telegram Chatbot to allow talking with ChatGPT using the OpenAI's API.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published