Skip to content
Examya: how I built a medical WhatsApp agent that processes exam orders

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.

MI

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