TL;DR
This project is a Personal Whatsapp Summary Assistant that uses N8n to interact with wwebjs and Google Gemini chat models to summarize WhatsApp conversations.
It listens for incoming messages from specific whatsApp groups and chats, processes them, and generates concise summaries using Gemini models or send prompts to Gemini for specific queries.
Features
- Listens for incoming WhatsApp messages from specified groups and chats.
- Summarizes conversations using Google Gemini chat models.
- Sends summaries back to your WhatsApp chats.
- Configurable to target specific WhatsApp groups and chats.
Motivation
As a collage student, for some reasons we create groups for different subjects, assignments, and projects. didn't like to scroll through long chats, this project idea came up because there was an internship whoever created Ai Agent will get selected. Which this helped get selected in the internship 😁.
Constraints
- I'm using my homelab to host n8n and wwebjs with docker compose, homelab is meant for local network usage and learning purposes, public access was not in my consideration when building the homelab, n8n needs https endpoint to work with webhooks, so tried using nginx proxy manager to expose n8n to public internet, where i found out that my isp blocks port 80 and 443 for residential connections, so used cloudflare tunnel to expose n8n to public internet.
- wwebjs uses whatsapp web with puppeteer under the hood, so you need to keep the session alive, which is handled by wwebjs, so this project is not meant for production and whatsapp/meta may ban your number if they detect unusual activity.
- Google Gemini models are not free, Only 20 tokens are free per day and limited to 5 request per minute, so if got a lot of messages, you may hit the limit quickly.
- This project is meant for personal use only, please don't use it for spamming or any illegal activities.
Project Structure
The project consists of two main components:
wwebjs service:
to handle whatsapp messages and provide endpoints for n8n to use as tools:
- Send to n8n: filter messages from specific groups and chats and send them to n8n via webhook.
- Chat History: provide chat history to n8n Ai agents when needed, only get last 20 messages.
- Reply: provide endpoint for n8n Ai agents to reply summarized messages back to my whatsapp chat.
- Search Chat: let n8n Ai agents to search for specific chat by name.
WhatsApp Groups and chats Messages filtering is done by wwebjs service, by default wwebjs listens to all incoming messages, and i only need summaries from my college groups and chats, so added filtering logic in wwebjs service to only send messages from specific groups and chats to n8n webhook.
N8n Workflow
to listen for incoming messages, process them, and generate summaries using Gemini models. The N8n workflow consists of the following key nodes:
- WebHook Trigger: Listens for incoming WhatsApp messages.
- Filter nodes: Three condition nodes to filter messages from specific groups and chats, if a Message Contents a media, and if the Message contents a command.
- Ai Agent nodes: Two Ai Agent nodes each has different system messages and prompts for handling groups and Private messages.
- Convert Node: Converts Base64 media to binary data.
- Wwebjs Tools: created Wwebjs endpoint for Ai agents to, Search chat, get chat messages, and reply.
Bugs and Improvements
- Currently, Ai agents can't handle rapid message bursts, if multiple messages are sent in quick succession, it will pass gemini rate limits and fail, so what we can do is implement a queue node to wait for other messages and send a batch of messages instead of sending each message individually.
- wwebjs service searching chat name is not accurate, it uses simple string matching, so if there are multiple chats with similar names, it may return the wrong chat, so we can improve the search logic
conclusion
This project was fun to do and learned a lot about n8n and wwebjs, and interconnecting different services together, yes Ai agents are cool and current hype but you can do a lot more with n8n without Ai agents, This was on of my coolest projects i did in my homelab, gave me a lot of confidence you i can build new stuff in short time. if you have any questions or suggestions, feel free to open an issue or contact me.

Top comments (0)