Filter the Noise, Focus on What Matters in WhatsApp.
WhatsApp-AI-Filter is an open-source project designed to help you manage information overload in WhatsApp groups. Running locally on your computer, this application monitors your specified WhatsApp groups and uses AI (leveraging APIs from providers like Perplexity AI) to intelligently filter messages based on your interests. It notifies you about relevant discussions, such as meetups in specific locations or conversations about particular topics, allowing you to focus on what truly matters and ignore the noise.
- Intelligent Filtering: Uses AI to identify and surface only the messages that are relevant to your interests.
- Customizable Focus: Define keywords and topics to tailor the filtering to your specific needs.
- Real-time Monitoring: Continuously monitors your chosen WhatsApp groups for new messages.
- Local Operation: Runs privately on your computer, ensuring your data stays secure.
- Notifications: Sends you direct WhatsApp messages for important and relevant content, often including a link back to the original message.
- Multi-AI Provider Support: Connects to both Perplexity AI (recommended) and OpenAI.
While the bot supports both OpenAI and Perplexity AI, Perplexity AI is highly recommended for its:
- Focus on Search and Real-time Information: Perplexity AI excels at providing concise, accurate, and up-to-date answers sourced from the web, which is often beneficial for real-time messaging contexts.
- Transparency: It provides sources for its answers, increasing trustworthiness.
- Efficiency: Often designed for quick, factual queries, potentially leading to lower latency for filtering.
This guide will walk you through setting up and running the WhatsApp AI Filter Bot on Unix-like systems (Linux, macOS, or WSL on Windows).
Before you begin, ensure you have the following installed:
- Node.js (v20 or newer): Download Node.js
- npm: Comes bundled with Node.js.
- Git: Download Git
First, clone the project repository to your local machine:
git clone https://github.com/avikalpg/whatsapp-ai-filter.git
cd whatsapp-ai-filter/
The setup.sh
script automates the core installation, build, and initial configuration steps. It's designed to be interactive, asking for your input and confirmation when necessary.
chmod +x setup.sh # Make the script executable
./setup.sh # Run the setup script
What the setup.sh
script does:
- Navigates into the
core/
directory. - Installs all Node.js dependencies (
npm install
). - Builds the TypeScript project (
npm run build
). - Checks for
pm2
global installation and attempts to install it if missing (may requiresudo
). - Interactively asks for your API keys (Perplexity AI and OpenAI). You must provide at least one key. It will then create the
.env
file for you based on your input. - Guides you through WhatsApp Web authentication by scanning a QR code in your console.
- Starts the bot using
pm2
. - Guides you through setting up
pm2
for automatic startup after system reboots (this step will typically require you to run asudo
command generated bypm2
).
Follow the on-screen prompts carefully!
The bot uses environment variables for sensitive information like API keys. These are stored in a .env
file within the core/
directory.
- A
.env.example
file is provided incore/
to show you the required variables. - Do not commit your actual
.env
file to Git! It's already in.gitignore
. - The
setup.sh
script handles the creation and population of this file based on your input.
Required Variables (at least one must be provided):
OPENAI_API_KEY
: Your API key for OpenAI.PERPLEXITY_API_KEY
: Your API key for Perplexity AI (recommended).
The core/ecosystem.config.js
file configures how PM2 runs your bot. It defines the application name, entry point, and logging behavior.
name
:whatsapp-ai-filter
script
:dist/index.js
(relative to thecore/
directory)log_file
: Logs are directed to files within thecore/logs/
directory.
Once the backend application is running and authenticated:
- It will monitor the WhatsApp groups you are part of.
- New messages in those groups will be sent to the configured AI API (Perplexity AI or OpenAI) for analysis.
- If a message is deemed relevant based on the application's logic and your configured interests, you will receive a direct message on your WhatsApp account from the same WhatsApp Web session. These notifications will often include a link back to the original message for quick access.
To update your bot to the latest version from the Git repository:
- Navigate to your
core/
directory:cd whatsapp-ai-filter/core/
- Run the update script:
chmod +x update.sh # Only needed once if you haven't done it ./update.sh
What the update.sh
script does:
- Pulls the latest changes from the
main
branch. - Installs any new or updated Node.js dependencies.
- Rebuilds the project.
- Restarts the bot process using PM2.
For automatic, regular updates (e.g., hourly), you can set up a cron job on your system.
-
Open your crontab for editing:
crontab -e
-
Add the following line to the end of the file. Remember to replace
/path/to/your/whatsapp-ai-filter/core/
with the actual absolute path on your system.0 * * * * /path/to/your/whatsapp-ai-filter/core/update.sh >> /path/to/your/whatsapp-ai-filter/core/logs/cron_output.log 2>&1
This example will run the update script every hour at the 0-minute mark.
-
Save and exit the crontab editor.
-
You can review cron job output in
core/logs/cron_output.log
for any errors or update notifications.
Once your bot is running with PM2, you can use these commands to manage it:
- Check status:
pm2 status
- View live logs:
pm2 logs whatsapp-ai-filter
- Stop the bot:
pm2 stop whatsapp-ai-filter
- Restart the bot:
pm2 restart whatsapp-ai-filter
- Delete the bot from PM2:
pm2 delete whatsapp-ai-filter
- Save current PM2 processes (for auto-restart on boot):
pm2 save
- The provided
setup.sh
andupdate.sh
scripts are designed for Unix-like operating systems (Linux, macOS). - Windows users can run these scripts using WSL (Windows Subsystem for Linux) or Git Bash, which provides a Unix-like environment.
- Native Windows batch (
.bat
) or PowerShell (.ps1
) scripts are not currently provided.
The project includes a landing page built with Next.js to provide information about WhatsApp-AI-Filter. For instructions on developing or building the landing page, please refer to the landing-page/README.md
file within that directory.
- Navigate to the
landing-page
directory:cd landing-page
- Follow the instructions in the
README.md
file there to install dependencies and run or build the landing page.
We welcome contributions! If you'd like to improve this bot, please follow these steps:
- Fork the repository and clone your own fork.
- Create a new branch (
git checkout -b feature/YourFeature
). - Make your changes and ensure they are well-tested.
- Commit your changes (
git commit -m 'Descriptive commit message with prefix like feat, fix, refactor or deploy'
). - Push to the branch (
git push origin feature/YourFeature
). - Open a Pull Request.
This project is licensed under the GNU General Public License v3.0.