Patient Experience
Contact Centres

Request prescription refills through AI chat

Workflow purpose

This guide demonstrates how to use Proto's AI agent to let patients request a refill of their repeat prescriptions without phoning the clinic or queueing at the pharmacy counter.

The workflow verifies the patient against the hospital system, lists the repeat prescriptions on their record, and lets them choose what they need. Each item is checked against your refill rules before anything is sent: requests that are too early are explained, items that need a review go to a doctor, and controlled medicines are never approved automatically. The patient chooses collection or delivery and leaves with a reference number.

The AI agent never gives dosing advice beyond the label held in your system, and anyone who mentions urgent symptoms is told where to get care and offered a nurse.

Who can benefit from this guide:

  • Hospital and clinic pharmacies handling repeat prescription requests
  • Primary care practices where refill calls take up front-desk time
  • Chronic care programmes supporting patients on long-term medicines
  • Health plans and HMOs running their own pharmacy services
  • Digital health teams adding self-service to patient channels

Request a prescription refill

This workflow verifies the patient, checks each repeat prescription against your refill rules and sends the request to the right queue 24/7. See how to build a prescription refill workflow.

Just starting with the platform?
For initial setup of your AI agent – including workspace setup, agent training, and channel deployment – please start here. This workflow guide assumes your AI agent is set up and ready for more advanced configurations.

1. Create a trigger

Start the flow when a patient asks for more of a medicine they already take.

  • Navigate to the Workflows tab in the AI agent settings.
  • Click New workflow and select Message received as the Workflow type.
  • Name the trigger (e.g. “Prescription Refill”) and add a short description (e.g. “Triggers if user wants to renew, refill or reorder a repeat prescription or a medicine they take regularly.”).
  • Add training phrases (e.g. “I need a repeat prescription”, “Refill my medication”, “I’m running out of my tablets”, “Can I reorder my inhaler”).

New prescriptions, and questions about what a medicine is for, belong with a doctor – add them to the trigger’s description as things it should not match, so the AI agent sends them to your appointment flow instead.

2. Screen for urgent symptoms

Check the opening message before anything else, so a patient who is unwell isn’t asked for their patient number first.

People often explain why they need a refill – “I’m out of my heart tablets and I’ve had chest pain since yesterday”. Add an LLM Processing action:

  • Input: {_user_input}
  • Model: your preferred model
  • Temperature: 0
  • System prompt: “You screen messages sent to a hospital pharmacy. Reply only with JSON: {"red_flag": "yes" | "no"}. Reply yes if the message mentions chest pain, difficulty breathing, signs of a stroke, severe bleeding, an allergic reaction, thoughts of self-harm, an overdose or a missed dose of a medicine the person says is urgent. If you are unsure, reply yes.”
  • Resulting variable: screen

Add a Set variable action – Variable: screen, Chat script: _.json_parse(screen).

Add a Branch action. If screen["red_flag"] == "no", continue to Step 3. Under Else – which also catches a reply that couldn’t be read – add a Jump action to Step 9. The safe default is always to show the urgent care message; a patient who is fine can carry on with their refill from there.

3. Verify the patient

Confirm who is asking before any prescription details are shown.

Add a Send message action:

“I can help you request a repeat prescription. First, I need to check your details.”

Add an Ask survey action. Action title: Patient verification

Field Variable Type Invalid reply
Patient number patient_number Text Please enter the patient number from your hospital card or appointment letter
Date of birth (DD/MM/YYYY) date_of_birth Text Please enter your date of birth as DD/MM/YYYY

Keep Enable skip off for both fields. Then add a Send API action:

  • HTTP method: POST
  • URL endpoint: your hospital system’s patient verification endpoint
  • Headers: the authorisation key your system requires
  • Body: patient_number and date_of_birth
  • Resulting variable: patient

Under Success, add a Branch: if patient["verified"] == true, store patient["id"] and patient["first_name"] with a Set variable action and continue. Under Else, tell the patient the details don’t match and Jump back to the survey. Count attempts with a Set variable action, and after a second failure send the pharmacy’s phone number and opening hours instead of trying again. Under Error and Timed out, apologise and give the same contact details – never fall back to showing anything unverified.

4. List the repeat prescriptions

Show only what is already on the patient’s record, so nobody types a medicine name from memory.

Add a Send API action:

  • HTTP method: GET
  • URL endpoint: your prescribing system’s repeat medicines endpoint, passing {patient["id"]}
  • Resulting variable: repeats

Add a Set variable action – Variable: repeat_count, Chat script: _.len(repeats) – then a Branch action:

Condition What happens
repeat_count == 0 Send message: “You don’t have any repeat prescriptions on your record. If you need a new prescription, I can help you book an appointment with your doctor.” Then a Jump to your appointment trigger – see medical appointment scheduling.
repeat_count <= 3 Send message with quick replies built from the list: {repeats[0]["name"]} | {repeats[1]["name"]} | {repeats[2]["name"]} | All of these. Empty quick replies are dropped, so the same message works for one, two or three items.
Else Send message with a numbered list – “1. {repeats[0][“name”]} {repeats[0][“strength”]}“, and so on – then continue to Step 5.

5. Choose the items

Let the patient pick everything they need in one go.

For the numbered list, add an Ask survey action. Action title: Refill selection

Field Variable Type Invalid reply
Reply with the numbers of the medicines you need, e.g. 1, 3 selected_items Text Please reply with the numbers from the list, separated by commas

For the quick reply path, add a Set variable action under each sub-trigger that stores the chosen item in selected_items.

If the patient asks how much to take, or whether they can change their dose, don’t let the AI agent answer from general knowledge. Reply with the label instructions held in your system – {repeats[0]["label_instructions"]} – and offer to connect them to a pharmacist with a Live agent handoff to your pharmacy team. Add the same rule to the Agent persona on the AI agent’s Agent tab: no dosing advice beyond the label.

6. Check the refill rules

Let your pharmacy system decide what can be refilled – the AI agent only explains the result.

Add a Send API action:

  • HTTP method: POST
  • URL endpoint: your pharmacy system’s refill check endpoint
  • Body: {patient["id"]} and {selected_items}
  • Resulting variable: refill_check

The response sorts each item into one of four lists. Add a separate Branch action for each list, with the condition _.len(refill_check["<list>"]) > 0, so a request with mixed items gets every message that applies:

List Rule Send message
ready Within the refill window, no review due “These can be refilled: {refill_check[“ready”]}.“
too_early Last supply should not have run out yet “It’s too early to refill {refill_check[“too_early”]}. You can request it from {refill_check[“next_date”]}.“
needs_review Review date passed, or the doctor has asked to see the patient “{refill_check[“needs_review”]} needs a review by your doctor before it can be refilled. I’ll send it to them.“
controlled Controlled medicines “{refill_check[“controlled”]} is a controlled medicine, so a doctor must approve every refill. I’ll send it to them.“

Controlled medicines always go to the doctor queue, whatever their refill date – never to the automatic ready list. Set this in the pharmacy system’s rules, not just in the chat, so no change to the workflow can override it.

If every item is too early, end with a Send message offering to remind them of the date and close the flow. Under Error and Timed out, send all selected items to the doctor queue in Step 8 rather than guessing.

7. Choose collection or delivery

Ask where the medicine should go once it is approved.

Add a Send message with quick replies: Collect from a pharmacy | Deliver to my home.

  • Under Collect from a pharmacy, add a Send API action that returns the patient’s usual pharmacy and nearby alternatives, then a Send message with quick replies built from the result, e.g. {pharmacies[0]["name"]} | {pharmacies[1]["name"]}. Store the choice in fulfilment.
  • Under Deliver to my home, show the address held on record and ask Is this still correct? with quick replies Yes | Use a different address. A different address is collected with an Ask survey Text field.

If your policy keeps controlled medicines to collection only, add a Branch: when _.len(refill_check["controlled"]) > 0, skip the delivery option and explain why. If delivery carries a fee, your pharmacy system can return a payment link for the AI agent to send – payment is never taken inside the chat.

8. Send the request and confirm

Put each item in front of the right people, with a reference the patient can quote.

Add a Branch action. When the ready list has items, add a Create ticket action:

  • Assignee: your pharmacy team
  • Subject: Repeat prescription – {patient_number}
  • Description: the ready items, the fulfilment choice and any delivery address
  • Full name and Email: from the verified record
  • Auto-apply tags: refill, ready

When the needs_review or controlled lists have items, add a second Create ticket assigned to your prescribing doctors’ team, tagged refill and doctor-review (plus controlled where it applies). If your pharmacy system takes orders directly, use a Send API POST in place of the first ticket and keep the ticket only for doctor review.

Then add a Send message:

“Thank you, {patient[“first_name”]}. Your request has been sent – your reference is {_new_ticket.short_id}. We’ll email you when it’s ready or if your doctor needs to speak to you.“

Pharmacists and doctors reply from the ticket in the Inbox. Check the teamspace’s overdue rule under Settings › Tickets › Overdue rules – it applies to every ticket. With Apply overdue status after set to 2 days and Exclude weekends on, no request waits unnoticed.

9. Advise urgent care and offer a nurse

Make sure a patient who is unwell is told where to get help, straight away.

Add a Send message:

“From what you’ve told me, you may need medical attention now. If you have chest pain, difficulty breathing, signs of a stroke or severe bleeding, call [emergency number] immediately or go to your nearest emergency department.”

Add quick replies: Speak to a nurse | Continue with my refill. Under Speak to a nurse, add a Live agent handoff action assigned to your nurse team, with Live agent availability check on. Under If there is no live agent online, repeat the emergency advice and give your out-of-hours number. Under Continue with my refill, add a Jump action to Step 3.

10. Test the flow

Validate every path before going live using the AI agent tester side panel.

  • Start with “I’ve run out of my blood pressure tablets and I’ve got chest pain” and confirm the urgent care message appears before verification.
  • Enter a wrong date of birth twice and confirm no prescriptions are shown.
  • Request one item that is too early, one needing review and one controlled medicine together, and check each message and ticket.
  • Ask “How many should I take?” and confirm the reply only repeats the label instructions.
  • Build and test in an undeployed version – Duplicate the live version on the Workflows tab – then Deploy when every path passes.

Finalise the AI agent deployment by configuring your preferred channels and languages.