Video demo(old-version): https://www.facebook.com/share/v/1PCci8RnYD/
This project automates chat replies (e.g., Messenger, WhatsApp) using screen automation with PyAutoGUI, clipboard handling via Pyperclip, and AI-generated responses powered by Groq. After starting, the program automatically clicks the chat icon at a predefined screen position, then continuously cycles through multiple chat slots by clicking different coordinates one by one, triggering chat automation scans for each conversation. It scans each chat for new incoming messages, generates and sends appropriate replies, skips responding if the last message was sent by the chatBot, and then moves on to the next chat. Once all configured chat positions are scanned, the process loops back to the first chat, enabling continuous, hands-free monitoring and automated replying across multiple conversations.
This project includes a dry-run mode and logging to support safe testing and debugging.
- Dry-run mode allows the bot to scan chats, detect the last sender, and decide whether a reply should be sent without clicking, typing, or sending messages. This makes it safe to test logic and demonstrate behavior without affecting real conversations.
- Logging records key actions such as chat scans, reply decisions (sent or skipped), and errors, making it easier to debug issues and understand the bot’s behavior during execution.
Together, these features help ensure reliable automation, safer testing, and clearer insight into how the bot operates.
- Continuously scans the selected chat area for new messages.
- Sends AI-generated replies based on your configured persona.
- Avoids replying if the last sender is “You sent”.
- Cycles through multiple chat threads in a loop.
- Logs actions and supports a safe dry-run mode.
- Python 3.7+
- Dependencies from requirements.txt
- A Groq API key (environment variable)
-
Clone the repo
git clone https://github.com/SagarBiswas-MultiHAT/ChatAutomation-AI-Assistant.git cd Chat-Automation-Bot -
Create & activate a virtual environment
python -m venv .venv # Windows .\.venv\Scripts\activate # macOS/Linux source .venv/bin/activate
-
Install dependencies
pip install -r requirements.txt
-
Set your Groq API key
PowerShell:
$env:GROQ_API_KEY = "your_groq_key_here" $env:GROQ_MODEL = "llama-3.1-8b-instant" # optional
-
Create config.json
copy config.example.json config.json
-
Run the bot
python 03_bot.py
Every loop it:
- Clicks the next chat in your list.
- Selects the chat area and copies it.
- Detects the last sender.
- If the last sender is you, it does nothing.
- If the last sender is the user, it generates a reply and sends it.
- Never reply when the last message is “You sent”.
- Only reply to new incoming user messages.
- Cycles through multiple chats each scan.
These settings are also embedded in 03_bot.py, but using config.json is recommended.
Important fields
coords.chat_icon— opens the chat list (clicked once at startup).coords.chat_list— list of chat positions to cycle through.coords.select_start/coords.select_end— selection box for chat text.coords.input_box— where responses are typed.timing.poll_interval— pause between scans.my_name— used to recognize your own messages.
Example (trimmed):
{
"coords": {
"chat_icon": [617, 1050],
"chat_list": [
[245, 248],
[245, 314],
[230, 373]
],
"select_start": [523, 183],
"select_end": [1397, 1013],
"input_box": [600, 1006]
},
"timing": {
"poll_interval": 2.0
},
"my_name": "You sent"
}Use the cursor helper:
python 01_get_cursor.pyMove your mouse to the target UI point and copy the coordinates it prints.
python 03_bot.py --dry-runThis runs the detection logic without clicking or typing.
-
Bot replies when it shouldn’t:
- Re-check your selection box (
select_start/select_end). It must include the “You sent” marker and recent messages. - Make sure
my_namematches how your UI labels your messages.
- Re-check your selection box (
-
Bot does nothing:
- Confirm the chat area is selectable and text is copied correctly.
- Verify clipboard permissions and your selection area.
-
Clicks are off:
- Re-capture coordinates using 01_get_cursor.py.
- PyAutoGUI failsafe is enabled: move the mouse to the top-left corner to stop.
- Use responsibly and follow the platform’s policies.
MIT License. See LICENSE.
For questions or suggestions, email: eng.sagar.aiub@gmail.com