The AI qualifies my WhatsApp conversations on its own
The AI reads the conversation, identifies the funnel stage, and updates the CRM on the spot, no manual typing. Business rules are locked in code, not just the prompt.
The problem
Nobody likes dealing with a CRM. But the longer the path to a sale gets, the less you can trust the team’s memory. Here that whole path lived inside WhatsApp: who asked what, when, what was agreed. The data existed, it just was not queryable.
What I built
- Collection. A Python script reads new messages via the Evolution API, since the last run.
- Classification. The Anthropic API reads the conversation and returns the funnel stage and a summary, without overwriting what was already in the CRM.
- Persistence. Local database, with per-message deduplication.
- Scheduling. Windows Task Scheduler runs at 07:30, with recovery if the machine was off.
- Triage queue. A separate sweep revisits the older history and drops the result into a queue, not straight into the funnel.
- Catalogue mirror. Local cache of the site’s API, so the contact record already shows the item they asked about.
Technical decisions
A simplification that also solved privacy. The first version ran through a cloud workflow orchestrator: it worked, but it was one more piece to maintain and it sent client conversations over the wire for no reason. I replaced it with a scheduled script, simpler and more private at the same time.
AI output treated as untrusted input. The classification is validated against a closed set of stages before it touches the database; anything outside that, it stays unclassified instead of storing an invented value. There are guards in code, not just the prompt: the model never closes a deal on its own and never moves someone out of their own category.
The human note beats the machine reading. Notes live in their own table, append-only, and the AI reads them with precedence over the conversation, never rewriting them. Before that, they shared a field with the automatic summary and disappeared with no error at all.
The sweep does not write to the funnel. Analysing the older history could scramble months of classification in one go. The sweep writes to a separate queue; a single click promotes someone into the base.
Deduplication at the source. Re-running is normal, whether from a network failure or a machine left off, and without a per-message deduplication key that would duplicate the history.
How I verified it
Re-running over the same window. First real load: 23 contacts created, 1 updated, zero errors. Ran it again over the same interval: 100% deduplication.
A pilot before turning the sweep loose on the whole history. I ran it on 15 conversations and checked them one by one: 13 were legitimate contacts. The longest one in the queue was from a supplier, and the classifier got it right, which a simple filter by conversation length would have gotten wrong.
Testing the connection guard in both directions. The most dangerous problem in the project: with WhatsApp disconnected, the API kept responding from its cache, and the sync would log “0 created, 0 updated, 0 errors” for weeks without anyone noticing. I started checking the connection before anything else and aborting if it is not open. Tested disconnected: it aborted. Reconnected: it imported 62 conversations.
It was the third case of the same kind in this project, after a backup that failed silently and a misconfigured username that inverted metrics without ever throwing an error. Every scheduled routine now writes its own result to a file, so silence stops looking like success.