Payment receipts over WhatsApp, read by AI and settled in the ERP
The receipt arrives on WhatsApp, an AI model extracts the data into a fixed format and the ERP reconciles it against the order through to settlement. Idempotent webhook, two clients, two AI providers.
- Industry
- Apparel and metalworking manufacturing
- Period
- 2026
- Role
- Sole author
- Scale
- 2 clients, 2 AI providers
2
AI providers, swappable by configuration
1 day
from spec to proof of concept at the second client
Idempotent
webhook with per-message deduplication
Technologies
Challenge
Customers who pay for an order upfront send the receipt over WhatsApp. On the other side, someone in finance opens each image or PDF, looks for the right order, posts the credit and then settles the receivable. It is repetitive work, done under pressure to release orders on time, and every typo turns into manual reconciliation at month end.
At a second client, the same channel receives expense receipts, which have to be classified and linked to the order they belong to.
Solution
Messaging. Both clients share one Evolution API installation on an AWS server, each with its own number and instance, connected by QR code straight from an ERP screen.
A webhook that survives the real world. WhatsApp redelivers a message when it does not get a fast reply, and the same contact sends several photos in a row. So the webhook deduplicates on the message ID, always answers success so as not to trigger redelivery, and only queues the work. Messages from the same number are serialised by a per-conversation lock, and the analysis runs in a separate job, outside the webhook’s response time.
AI with a contract. The model does not return free text: it returns JSON validated against a schema, with amount, date, merchant, company tax ID, category and payment method. The amount is stored in cents, a refusal or failure from the model becomes its own status for human review, and a value corrected by a person takes precedence over the AI’s without erasing the original, for audit. The first client runs on OpenAI; the second on Anthropic’s Claude. Switching provider is configuration.
Reconciliation and settlement. The receipt is matched to the order by amount, or manually when it is ambiguous. From there the ERP posts the prepayment and a job settles the receivable. Replies to the customer over WhatsApp go out serialised, with spacing and jitter, so the number is not treated as a bulk sender.
A monitor shows each receipt with the file alongside, what the AI read and where it stands.
Outcome
On the happy path nobody types the receipt in: it arrives, gets read, reconciled and settled. Anything the AI cannot read with confidence lands in a review queue with the file next to it, instead of becoming a wrong posting. At the second client, the proof of concept shipped in one day, from scratch, reusing the messaging infrastructure and splitting the build into four specs implemented in parallel.
What this case shows
AI came in as a component of a flow with a contract, not as the one making decisions. The output schema, the failure status and the precedence of human correction are what make it safe to write the answer straight into the ERP. And the tedious parts of a WhatsApp integration, such as redelivery, message bursts and the risk of being blocked, were handled in the design rather than discovered in production.
Stuck on a term? There is a glossary. Glossary