An open API service indexing awesome lists of open source software.

https://github.com/trivediayush/auto_reply_bot

Model to automate responses in a chat application. The program monitors chat messages, checks if the last message is from a specific sender, and generates an appropriate response.
https://github.com/trivediayush/auto_reply_bot

automation autoreply message whatsapp-bot

Last synced: 4 months ago
JSON representation

Model to automate responses in a chat application. The program monitors chat messages, checks if the last message is from a specific sender, and generates an appropriate response.

Awesome Lists containing this project

README

          

# AI Chat Responder

This project uses Python libraries such as `pyautogui`, `pyperclip`, and OpenAI's GPT-3.5 model to automate responses in a chat application. The program monitors chat messages, checks if the last message is from a specific sender, and generates an appropriate response using the OpenAI API.

## Features

- **Automatic Chat Response**: Automatically sends a response based on the last message in the chat.
- **OpenAI Integration**: Uses GPT-3.5 to generate natural language responses.
- **Clipboard Operations**: Uses `pyperclip` to handle copied chat text.
- **GUI Automation**: Uses `pyautogui` to interact with the chat application, such as clicking, copying text, and sending responses.

## Prerequisites

Before running the program, make sure you have the following installed:

- Python 3.x
- [PyAutoGUI](https://pyautogui.readthedocs.io/) for GUI automation.
- [Pyperclip](https://pyperclip.readthedocs.io/) for clipboard operations.
- [OpenAI Python Client](https://openai.com/) for GPT-3 integration.

You can install the required libraries using pip:

```bash
pip install pyautogui pyperclip openai
```

## How It Works
1. Monitor the Chat: The program continuously monitors the chat application. It checks if the last message is from a specific sender.
2. Message Extraction: If the last message is from the defined sender (e.g., "Aditya Badgotiya"), the program extracts the chat history.
3. Generate Response: The chat history is sent to OpenAI's GPT-3.5 model to generate a response that mimics the style of a predefined personality.
4. Send Response: Once the response is generated, it is copied to the clipboard and automatically pasted and sent to the chat using pyautogui.

## Setup Instructions
Clone the Repository (if applicable):
```bash
git clone https://github.com/trivediayush/auto_reply_bot.git
```
```
cd ai-chat-responder
```

- Set Up OpenAI API Key: Ensure you have an OpenAI API key. You can get one from OpenAI. Insert your API key in the code:

- python
```
client = OpenAI(api_key="your_api_key")
```

- Adjust Coordinates: The program uses specific screen coordinates to interact with the chat application. You may need to adjust the coordinates to match the location of your chat window and input fields. Use pyautogui.position() to help find the correct screen coordinates.

- Run the Program: Once the setup is complete, run the program:

```bash
python chat_responder.py
```
## Code Overview
- isLast_msg_frm_sender: A function that checks if the last message in the chat log is from a particular sender.
- OpenAI Integration: The program sends the extracted chat history to OpenAI's GPT-3.5 to generate a response in a predefined style (Ayush's personality).
- GUI Automation: pyautogui handles mouse clicks, dragging to select the chat, copying text, and pasting the generated response back into the chat input box.

## Customization
- Sender Name: The default sender name is set to "Aditya Badgotiya", but you can change this to any name you'd like in the isLast_msg_frm_sender function.
- Response Style: Modify the system message within the completion call to adjust the personality or tone of the responses generated by GPT-3.5.

## License
Apache License, Version 2.0, January 2004, http://www.apache.org/licenses/