Examya: how I built a medical WhatsApp agent that processes exam orders
Technical details of implementing the Shuri agent in Examya, a system for processing medical orders via WhatsApp with FONASA integration.
Mario Inostroza
I spent the last few days fixing complex issues in Examya’s medical order flow. The system has a WhatsApp agent called Shuri that manages everything from the initial consultation to order creation.
The main challenge was state persistence between messages. Users reported losing context between interactions. The flow should be: user describes symptoms → system suggests exams → user confirms → order gets generated. Instead, buttons and state would reset.
I found the problem was in how Redis state was handled between messages. The solution was updating the flow to keep purchase.stage persistent even across separate messages. I also added detection for confirmation messages like “yes, the full panel” to prevent them from being misclassified as package requests.
Another critical issue was FONASA code handling. The symptom flow generated suggestions with exam names truncated to 40 characters. But the quoting system required exact FONASA codes. The solution was prioritizing codes over names in the quoting flow.
FONASA integration was particularly delicate. The API requires exact RUT number format and strict validations. I implemented validation layers before each API call to avoid ambiguous responses.
FONASA integration also handles the copayment tiers (A, B, C, D) that determine what the patient pays out of pocket. The system automatically validates the tier based on the patient’s RUT and adjusts prices before generating the order.
Tests showed the agent now correctly handles the complete flow. Improvements in state persistence and data validation notably reduced interpretation errors. The system is now production-ready.
The Shuri agent represents an interesting example of combining conversational AI with traditional medical APIs. The key is maintaining clarity between conversational logic and healthcare system constraints.
Next steps include integrating more exams from the catalog and optimizing response times. The goal is making the process as transparent as possible for patients.
WhatsApp remains the ideal channel for this type of service due to its massive adoption in Chile. The medical exam integration demonstrates how messaging platforms can solve real healthcare problems.
If you’re interested in this type of systems or have questions about the implementation, contact me on WhatsApp or X. I’m open to sharing more technical details or collaborating on similar projects.
Related reading
In this series
How I Built Patagonia's First Private COVID PCR Lab (And Why I Ended Up Building AI)
In March 2021, I hoisted 300 kg of biosafety cabinet by crane to a second floor during lockdown. By May we were running the first private COVID PCR tests in Chilean Patagonia. The nights that followed became the real origin of Examya.
In this series
pgvector + Embeddings in Production: The Foundation of Medical Reasoning in Examya
Architecture for semantic search and text similarity in production with pgvector, pg_trgm, and real MINSAL data.
In this series
DeepEval: how I measure the quality of my medical agent with objective metrics
How I built an evaluation layer with DeepEval to measure the quality of Shuri, Examya's medical agent. With real data: from 20% to 70% on E2E, custom metrics for Chile's FONASA system, and why gpt-5-nano doesn't work for structured output.