Pharmacy Virtual Assistant
2025A multi-agent virtual assistant for retail pharmacy, designed and prototyped as a proof of concept.
Figma · Voiceflow · Airtable REST API · SSML
Role
Wrote the system specification, wireframed the interaction flow in Figma, and authored the intent model with its training utterances. Built the prototype in Voiceflow across 27 nodes, including live API integration with a synthetic Airtable database and a RAG knowledge base covering FAQs (hours, address, etc.).
Summary
People contact a pharmacy with three kinds of questions: general ones, questions about their own prescriptions, and clinical ones. I designed a multi-agent virtual assistant for a fictional pharmacy that keeps the three apart.
Key decisions
- Identity gate. Patient records sit behind a verification step that is the only route to them in the flow, so privacy does not depend on a model obeying a prompt.
- Clinical escalation. The router is trained to send clinical questions to a human. Unlike the identity gate, this relies on a model, because the router has to recognize the question as clinical. That's why missed clinical questions are a key measure for a pilot.
- Keypad fallback. A caller whose date of birth is misheard twice switches to keypad entry.
The result is a written specification and a 27-node Voiceflow prototype. In testing, the prototype verified a user against a live database and read back the status of each of their prescriptions in plain language. Other paths were only partly tested (see Outcome). In a pilot I would measure false verifications, clinical questions the router missed, and which callers end up on the keypad.
Problem
People contact a pharmacy for three kinds of help: general information ("How late are you open today?"), their own prescriptions ("Do I have any refills left on my inhaler?"), and professional advice ("Is it safe to take aspirin that expired last month?"). The first is routine. The second involves protected patient information. The third needs a pharmacist.
One agent handling all three has to remember, on every turn, not to read a record until it knows who it's talking to. If the only privacy control is a line in the prompt, privacy depends on the model following it every time. And an agent that prioritizes containment over compliance will eventually offer medical advice.
I designed and prototyped this assistant as a proof of concept. The goal was to deliver a specification that an engineering team could build from.
Architecture
Scroll diagramsideways for more →
The full interaction flow in Figma, organized around one axis: whether an intent requires patient verification. Everything on the right of the canvas is unreachable until the API call in the middle returns a match. The identity-repair loop is the branch that checks the values submitted on a retry against those already captured, rather than firing a duplicate API call. Click to zoom.
Interaction Decisions
Some interaction design choices and the concrete failures they prevent.
A dedicated Identity Gate Agent checks name and date of birth against the live database before any other agent can reach patient data. It is the only path there in the graph, and it confirms "Thank you, your identity has been verified" before sharing anything protected.
Prevents: A persistent or persuasive user talking a single agent into revealing someone else's prescriptions.
The verification flow is only triggered when an intent requires access to protected data. A user asking about store hours is never asked who they are.
Prevents: Making everyone authenticate to learn whether the pharmacy is open on Sunday, which teaches users to see verification as an obstacle.
If speech-to-text fails to parse a date of birth twice, the agent switches to keypad entry and gives an example aloud: "for example, 0-5-1-2-1-9-8-0 for May twelfth, 1980."
Prevents: A user stuck repeating themselves to a recognizer that can't understand them. Spoken dates are easy to mishear ("oh five twelve eighty" and "May twelfth nineteen eighty" are the same date), and recognition is least reliable for older users, non-native speakers, and accents underrepresented in training data, so that loop falls hardest on them.
Verification retries are capped at three. A retry with the same name and date of birth isn't sent to the database again. At the cap, the agent explains why before transferring: "For your security and privacy, I cannot access patient records without verification."
Prevents: Spending a user's attempts on a question the database already answered, and a gate that either stonewalls without a reason or quietly relaxes to end an awkward conversation.
Clinical questions (side effects, dosage, interactions, "can I take this expired pill") are routed to a pharmacist, and no agent is designed to answer them, even with a hedge.
Prevents: A plausible but unverified clinical answer given to a user who can't tell whether it's right.
A user can ask for a person from the first turn. On a clinical question, the assistant says it can't answer and offers a transfer, which the user can turn down.
Prevents: A user having to fail at something before they're allowed to reach a human.
Each transfer records why it happened (CLINICAL_QUERY, AUTH_FAILED, USER_REQUESTED) before it executes.
Prevents: A pharmacist picking up a conversation with no idea why it arrived, and an operations team reconstructing escalation causes from transcripts.
Content Design
The database stores prescription status the way a pharmacy technician needs it on screen. Several of those values are unsafe to show or say to the patient. "On Hold" sounds like the pharmacy is withholding the medication. "Refill Req Sent" is not a sentence. "No Refills Remaining" is accurate but doesn't say what to do next.
So each raw value maps to one of five categories, and each category to one authored sentence. A value nobody anticipated still lands in a category, so the user still gets a real answer.
Scroll tablesideways for more →
| Raw database value | Normalized category | What the user hears |
|---|---|---|
| Filled · Ready · Ready for Pickup | READY | …is filled and ready for pickup at our main pharmacy counter. |
| Pending Doctor · Refill Req Sent | AWAITING_PRESCRIBER | …is awaiting prescriber authorization. We sent a request to your doctor. |
| Expired · No Refills Remaining | EXPIRED | …has expired with no remaining refills. We'll need a new prescription from your provider. |
| Prior Auth Required · Insurance Hold | INSURANCE_DELAY | …is currently delayed pending insurance prior authorization. |
| null · any unmapped value | OTHER | …is actively being processed by our pharmacy staff. |
Two of the sentences carry the next step. EXPIRED says the provider has to write a new prescription. AWAITING_PRESCRIBER says the pharmacy already asked the doctor, so the user doesn't call to ask again.
For voice, delivery is specified too. List items are separated by 200ms SSML breaks, with falling intonation only on the last, so the user can hear when the list ends. Dates and numbers are read as digits ("one nine four two," not "one thousand nine hundred forty-two"), because a user confirming their date of birth needs to hear the digits they said.
On the input side, training utterances come from how users actually ask ("is my script ready," "did my doctor call one in"). There are 22 across the patient-specific intents, plus a 34-value entity model for medication names, dosage forms and units, task types, and insurance carriers.
Outcome
The result is a 27-node Voiceflow prototype and a specification, including a state schema and API contract, written for an engineer to build from. In the prototype I confirmed that FAQ questions reached the FAQ agent and got answers, that a correct name and date of birth returned the matching record from the live database, and that the assistant then read back the status of each of that patient's prescriptions. Matching a medication the user named was built but not confirmed working. Voiceflow's trial credits ran out while I was still debugging, so the keypad fallback and clinical escalation were never tested, and there is no public demo. The specification predates the build and differs from it in two places, noted in the appendix.
Recommended Evaluation Protocol
None of this has been measured. I was the prototype's only user, testing against a synthetic database, and only some paths ran (see Outcome). This is the plan for a pilot.
Containment (the share of conversations that end without a human) is the usual headline metric, and the wrong one here. Every clinical question is a planned transfer, so chasing containment would push the system to answer the questions it exists to refuse.
False-verification rate
Proposed: not measuredHow often the gate opens for the wrong person. Target: zero.
Why this one: Name plus date of birth is imperfect, and two patients can share both. This measures whether the system does its main job.
Gate failures, split by cause
Proposed: not measuredOf users never verified, how many were the wrong person correctly refused, and how many were the right person the recognizer couldn't hear.
Why this one: These are opposite failures with opposite fixes, and a single failure rate hides which one is happening.
Keypad fallback rate, by group
Proposed: not measuredHow often the keypad fallback fires, segmented by age band, region, and time of day.
Why this one: This is the accessibility measure. If one group hits the fallback far more often, the primary path is failing them, and an overall success rate won't show it.
Escalation precision, both directions
Proposed: not measuredOf conversations transferred as clinical, how many a pharmacist agrees were clinical. Also, how many clinical questions the router missed and the assistant answered.
Why this one: Over-escalation shows up in the transfer log. Under-escalation, the failure the design exists to prevent, can only be found by sampling conversations that weren't transferred.
Status comprehension
Proposed: not measuredWhether a user can say what happens next after hearing or reading a status.
Why this one: It's cheap to test: five users and one question, "so what do you do now?" If EXPIRED doesn't produce "call my doctor," the sentence is wrong.
What Transfers
Little here is specific to pharmacy. The design rests on three structures found in any regulated service, such as claims, insurance, banking, and benefits.
A record class that has to stay behind an identity check
Prescriptions here; claim files and account balances elsewhere. The question is where the check lives: as a prompt instruction the model must follow every turn, or as a boundary in the flow with no path around it. The two behave the same until a user pushes.
A question class that belongs to a licensed human
Dosage here; coverage decisions and financial or legal advice elsewhere. The failure is the same in each: a fluent answer that turns out to be wrong, and a user who acts on it. A hedge at the start doesn't change what they do.
A user who doesn't know which class they're in
Users don't sort their own questions, and the one with the most urgent question is the least likely to phrase it in the system's terms. That's why the clinical branch can interrupt at any point.
Appendix
Explorations
Selected: A Figma wireframe of the full interaction flow, walked end to end before any agent logic existed.
Rejected: Building directly in Voiceflow first was rejected. The identity-gate branching and the escalation paths needed to be legible on a canvas (where an unhandled branch or an escalation with no trigger is visible at a glance) before being committed to a tool that makes structural changes expensive.
Selected: Organizing the entire wireframe around a single axis: whether a given intent requires patient verification. The canvas is split into a "Verification: NOT Required" half and a "Verification: REQUIRED" half, and every intent is placed on one side or the other before anything else about it is designed.
Rejected: Verifying every user at the top of the interaction was rejected, even though it is simpler to build and simpler to reason about. It would mean asking a user to prove their identity to find out whether the pharmacy is open on Sunday.
Selected: Routing clinical questions to a human as a hard interrupt, from any point in the interaction.
Rejected: A hedged clinical answer ("I'm not a pharmacist, but generally...") was rejected. It is the most tempting option in the design, because it feels helpful and it is what a fluent model will do by default.
Selected: A synthetic Airtable database populated with real prescription shapes: eleven fields per record including sig directions, prescriber, date written, refills remaining, and fill history.
Rejected: A flat mock lookup returning a canned status string was rejected. The disambiguation flow, the status-normalization matrix, and the multi-prescription readout are only designable against records that have the messiness of real ones: multiple scripts per patient, the same medication at different strengths, statuses that do not map cleanly onto anything a user would recognize.
Guardrails & Human Oversight
Each card pairs a design concern with what the assistant does about it and where the specification says so.
User control
A user can ask for a person at any point. The Human Escalation Agent sits alongside the router, so a user can reach it with their first message. On a clinical question, the assistant explains that it can't answer and offers a transfer, which the user can accept or decline.
Figma wireframe, clinical branch ("Explain cannot answer" → "Offer transfer" → Yes/No); specification §5, Agent 5, trigger 3
Error recovery
After two failed attempts to recognize a spoken date of birth, the agent switches to keypad entry and gives an example: "enter your 8-digit date of birth, for example 0-5-1-2-1-9-8-0 for May twelfth, 1980." Without the example, "8-digit date of birth" is ambiguous.
specification §5, Agent 2, step 2 (DOB capture and fallback mechanics)
Repair
If a second attempt repeats the same name and date of birth, the flow doesn't query the database again. It checks the new input against the values already captured and, when they match, tells the user no record was found.
Figma wireframe, identity-repair branch ("Match existing variables?" → Yes → "Inform user no record found")
Transparency
At the retry cap, the user is told why and what happens next: "For your security and privacy, I cannot access patient records without verification. I will transfer you to a pharmacy team member who can help." The gate stays closed, and the user gets an explanation.
specification §5, Agent 2, step 3 (retries ≥ 3)
Human oversight
Each escalation trigger (clinical question, failed authentication, user request) writes an audit reason to shared state before the transfer: CLINICAL_QUERY, AUTH_FAILED, or USER_REQUESTED. Why a conversation left the assistant is recorded as it happens, so nobody has to work it out from transcripts later.
specification §3, v_transfer_reason; §5, Agent 5 triggers
Feedback
The assistant confirms verification ("Thank you, your identity has been verified") before sharing anything protected. The user knows the gate has opened and isn't left wondering whether the system is looking something up or still checking who they are.
specification §5, Agent 2, step 3 (1 record returned)
Iteration
Wireframe → prototype: six transactions specified, one built
Shipped: The Figma flow mapped six patient-specific transactions sitting behind the identity gate (status, history, billing, refill, hold, and billing change), each with its own API call and its own report-back to the user.
Broke: Building all six would have produced six shallow branches and no evidence that the hard parts worked: the gate in front of all of them and the spoken readout after it.
Fixed: The prototype builds one transaction (prescription status): routing, verification, the Airtable lookup, disambiguation across multiple prescriptions, and a normalized spoken answer. Routing, verification, and reading back each prescription's status ran in testing; matching a medication the user named was not confirmed. The other five remain specified in the wireframe and were not built.
Multi-prescription readout: hardcoded slots → indexed loop
Shipped: The first version of the readout handled a patient's medications as three named slots (med_1_name, med_2_name, med_3_name, each with its own index variable) because every patient in the synthetic database has two or three prescriptions.
Broke: Three slots covered every record that happened to exist and would have failed on the fourth. The readout logic also had to be written once per slot, which is three places for the phrasing to drift apart, on a channel where the phrasing is all the user gets.
Fixed: Replaced with a single indexed loop over the returned array: current_index, current_medication_name, has_more_medications, medication_count. One authored sentence is designed to serve a patient with two prescriptions or twelve. Both generations are still visible in the exported project's variable registry: the abandoned med_1/med_2/med_3 slots sit alongside the loop variables that replaced them.
Debugging the Airtable response shape
Shipped: The identity lookup was written expecting the patient record to carry the prescriptions themselves.
Broke: It does not. Airtable returns the patient record plus an array of linked prescription record IDs (the prescriptions are a second hop away), so the readout was reaching for medication names that were not in the payload it had.
Fixed: A debug node was dropped into the canvas to print the captured fields (patient ID, record ID, and the prescription ID array), so the actual response shape was visible on the canvas. The lookup was then restructured around the two-hop reality. That node is still in the exported project.
Specification hand-off
I built this solo and wrote the specification as a hand-off document: a system overview and developer prompt that someone who did not design the system could build from.
The specification covers the details an engineer would otherwise have to decide alone: every state variable's name, type, and default; the exact filterByFormula the identity lookup sends and the field IDs it uses; the full mapping from raw database status to spoken sentence; and the retry cap as the number 3. Anything left unspecified gets decided during implementation by whoever reaches it first.
The built prototype and the specification differ in two places. The spec describes a Prescription Status Agent with three disambiguation branches; the build resolves status through six inquiry-type outcomes. The wireframe scopes six patient-specific transactions; the prototype builds one. The specification is unchanged from before the build, so both differences can be seen in the artifacts.
Two artifacts from the specification, reproduced as written. The first is the shared state every agent reads and writes; the second is the request the identity gate sends.
Scroll tablesideways for more →
| Variable | Type | Default | Role |
|---|---|---|---|
| v_first_name | String | "" | Spoken or transcribed first name of the caller |
| v_last_name | String | "" | Spoken or transcribed last name of the caller |
| v_dob | String (ISO) | "" | Date of birth, normalized to YYYY-MM-DD |
| v_dob_dtmf | String | "" | Digits captured via the keypad fallback, MMDDYYYY |
| v_is_authenticated | Boolean | false | The gate. Must be true before any PHI node is reachable |
| v_auth_retries | Number | 0 | Verification failure counter; cap is 3 |
| v_airtable_record_id | String | "" | Airtable recordId, populated only on a positive match |
| v_patient_id | String | "" | Internal patient ID retrieved from the matched record |
| v_rx_raw_data | Array | [] | Raw prescription records returned from the Airtable payload |
| v_target_drug_name | String | "" | Medication named by the caller during disambiguation |
| v_rx_status_category | String | "" | Normalized status: READY · AWAITING_PRESCRIBER · EXPIRED · INSURANCE_DELAY · OTHER |
| v_intent_category | String | "" | Router output: FAQ · PATIENT_SPECIFIC · CLINICAL |
| v_transfer_reason | String | "" | Audit reason written before escalation: CLINICAL_QUERY · AUTH_FAILED · USER_REQUESTED |
Scroll codesideways for more →
GET https://api.airtable.com/v0/{baseId}/{tableId}
Authorization: Bearer {AIRTABLE_API_KEY}
Content-Type: application/json
filterByFormula = AND(
{First Name} = '{v_first_name}',
{Last Name} = '{v_last_name}',
{Date of Birth} = '{v_dob}'
)
→ 1 record set v_is_authenticated = true, store recordId + patient ID,
load prescriptions into v_rx_raw_data
→ 0 records increment v_auth_retries; at 3, set v_transfer_reason
= AUTH_FAILED and route to Human EscalationThe specification puts all three verification parameters in one query. A staged check (confirm the surname, then ask for the date of birth) would leak information: a user would learn from the second prompt that the first value matched somebody. One query returns one record or zero, and zero is the only thing an unverified user is ever told.