How I Built an AI-Powered Lab Report Delivery Automation Using n8n, WhatsApp & Supabase

I recently built a workflow to automate lab report status updates and PDF delivery through WhatsApp using n8n.

The goal was to simplify the process of keeping patients updated about their lab reports and delivering reports without relying on manual communication.

:gear: How does it work?

The workflow combines n8n with OpenAI, Supabase, and WhatsApp to handle the report delivery process.

Here’s what the project focuses on:

- WhatsApp Integration: Communicating with patients through WhatsApp.

- AI Agent: Adding AI-powered processing to the workflow.

- Supabase: Managing the required data.

- PDF Delivery: Sending lab reports directly to patients.

- Status Notifications: Keeping patients informed about their report status.

:hammer_and_wrench: Tools & Technologies

- n8n

- OpenAI

- Supabase

- WhatsApp API

:movie_camera: Watch the complete walkthrough

I also recorded a video explaining the project and demonstrating the workflow.

:inbox_tray: Get the workflow

You can explore and use the published workflow template here:

I’m sharing this project with the community to exchange ideas, learn from other builders, and explore how n8n can solve practical business problems.

I’d love to hear your thoughts:

1. What improvements would you suggest for this workflow?

2. What additional features would make this automation more useful for laboratories?

Looking forward to your feedback! :rocket:

@automatebybilal nice build, and checking the sender’s number against the report is a good call for medical reports.

One feature I’d add is a message when the report status changes to ready, so patients don’t have to keep asking. But there’s one catch to plan for before you build it.

The report is usually ready hours or days after the patient last messaged, which means the 24-hour customer service window has closed. Outside that window WhatsApp only delivers approved templates, so a normal text or the PDF itself won’t arrive. You’d need a Utility template approved by Meta first, something like “Your report {{1}} is ready, reply REPORT to receive it”.

The tricky part is that a blocked send doesn’t fail in n8n. The WhatsApp node still gets a 200 and a message ID back, and the failure only comes later to your webhook as a status event with error 131047. So the workflow looks fine and the patient actually got nothing. If you save the message ID from each send against the report and set the trigger’s “Receive Message Status Updates” to Failed, you can match those back and let the lab know who wasn’t reached.

Nice side effect: when the patient replies REPORT, the window opens again, so your existing flow can send the PDF as a normal document without any template.

1 curtida

Thanks for the feedback! That’s a really useful suggestion. I hadn’t considered the delivery issue after the 24-hour window. Tracking failed messages through webhooks is definitely something worth adding. I’ll look into implementing this in the next version. Appreciate your help!

Glad it helped. Just note the webhook only tells you the message failed (131047). To actually deliver the report outside the 24h window you still need an approved Utility template, so I’d do that first.