Blog

    Automated Medical Intake With Twilio and ChatGPT: SMS Consent, BAAs and EHR Write-Back

    By GauravJune 23, 20269 mins read
    On this page

    A clinic that texts patients a few intake questions before a visit can save the front desk a lot of phone calls. Twilio carries the messages, and a model such as ChatGPT, called through the OpenAI API, can turn loose replies like "left knee, since March, worse on stairs" into structured fields.

    This post covers how that pipeline is built and where it fails: which services need a business associate agreement, how texting consent and STOP replies work, how answers reach the EHR, and why a person reviews every intake before it is filed.

    What is automated medical intake with Twilio and ChatGPT?

    Planning patient intake by text?

    Our AI team builds conversational intake that asks, extracts and files answers for staff review.

    Automated medical intake with Twilio and ChatGPT is a text-message workflow in which Twilio sends intake questions to a patient's phone and an OpenAI model turns the replies into structured answers that staff review before they reach the EHR. Agnotic Technologies builds these pipelines so every service that handles a reply runs under a signed BAA.

    The model does the reading, not the deciding. It extracts what the patient said into fields; it does not triage, diagnose or answer with medical advice.

    How does an SMS intake flow work end to end?

    An SMS intake flow is a chain of services, and the patient's replies pass through every one of them. Each link needs its own safeguards and its own agreement.

    SMS intake flow from the patient's phone through Twilio Programmable SMS to the intake service, which calls the OpenAI API for structured extraction, then to staff review and the EHR, with a consent and audit lane covering opt-outs and BAAs
    • Step 1, trigger: the scheduling system books a visit and asks the intake service to start a conversation for that appointment.
    • Step 2, send: the intake service checks the consent flag, then sends the first question through Twilio Programmable SMS.
    • Step 3, receive: Twilio posts each reply to a signed webhook on the intake service, which stores it with the conversation.
    • Step 4, extract: the intake service sends the conversation to the OpenAI API with a fixed schema and gets structured fields back.
    • Step 5, review and file: a staff member checks the draft, corrects it and approves it, and only then is it written to the EHR.

    Keep the conversation state in your own database, not in the model. The model sees one request at a time and keeps nothing; your service decides which question comes next.

    Which services need a BAA?

    Every service that stores or transmits the patient's replies needs a business associate agreement. In an SMS intake pipeline that usually means the messaging provider, the model provider and the cloud host that runs the intake service and its database.

    Twilio's HIPAA Eligible Services list includes Programmable SMS, Programmable MMS and messaging features such as Advanced Opt-out and the Consent Management API, and a covered entity or business associate must sign Twilio's Business Associate Agreement before using them with PHI.

    OpenAI says an organization must enter into a Business Associate Agreement before using the OpenAI API with protected health information, and that accepting the BAA does not by itself make an application HIPAA compliant.

    Check each eligible list against the exact features you call, including logging and storage settings. A BAA for the API organization also does not cover a staff member who pastes patient texts into a separate ChatGPT workspace.

    Consent work has two halves: recording that the patient agreed to receive texts, and stopping quickly when they withdraw. Federal texting rules set the floor for the second half.

    Under 47 CFR 64.1200(a)(10), a person may revoke consent to texts by any reasonable method; a reply of stop, quit, end, revoke, opt out, cancel or unsubscribe counts per se, and the request must be honored within a reasonable time not exceeding ten business days.

    • Consent record: who agreed, to which number, for which kind of message, when and through which form.
    • Keyword handling: STOP and the other listed words end the conversation and set a flag the scheduler checks before any later send.
    • Free-text refusals: replies such as "please stop texting me" are treated as an opt-out, and unclear ones go to staff rather than being ignored.
    • Fallback: a clinic phone number in the first message, so patients who prefer a call know where to go.

    Build the opt-out check into the send path itself, so no reminder job or second system can text a number that has withdrawn.

    Keep sensitive details out of the text body

    Text messages sit on lock screens and shared phones, so the message body should carry as little health information as possible. Ask for the reason for the visit, but do not repeat diagnoses, medication names or results back to the patient.

    • Wrong-number guard: the first message asks the patient to reply YES before any visit details are sent, because phone numbers get reassigned.
    • Neutral wording: "your upcoming visit" rather than the department or condition.
    • Secure link: long or sensitive sections, such as mental health screening, move to a web form behind a one-time link.
    • Patient choice: the patient can switch to a phone call or the portal at any point.

    How does the model turn replies into structured intake?

    The model fills a fixed schema, field by field, from the patient's own words. It never invents a value: a field the patient did not answer stays empty and becomes the next question.

    • Schema: reason for visit, symptom duration, current medications, allergies, preferred pharmacy and a free-text note.
    • Source quote: each extracted value keeps the reply text it came from, so the reviewer can check it at a glance.
    • Unsure flag: the model marks fields it could not fill or was unsure about, instead of guessing.
    • Validation: your code, not the model, checks dates, numbers and allowed values before saving.

    Treat every reply as untrusted input. A patient, or whoever holds the phone, can type instructions aimed at the model, so patient text goes in a separate data field and the model has no tools that send messages or write records.

    How do intake answers reach the EHR?

    Approved answers reach the EHR through its own supported interfaces, never through the model writing to it. Common targets are an HL7 FHIR QuestionnaireResponse, discrete resources, or an HL7 v2 message or document for older systems.

    • FHIR QuestionnaireResponse: stores the whole intake as answered, linked to the questionnaire definition and the appointment.
    • Discrete resources: allergies and medications written as their own records, only after a clinician reconciles them.
    • HL7 v2 or document: where the EHR has no write API, a note or document attached to the encounter.
    • Status: drafts stay in the intake service, and only approved versions are sent, with the reviewer recorded.

    Confirm what your EHR accepts before promising structured write-back. Many sites accept a document or questionnaire answer from an outside app but keep allergy and medication lists under clinician control.

    Human review before anything is filed

    A staff member approves every intake before it is filed, and the review screen is built for speed. Each field shows the extracted value next to the patient's original words, with unsure fields listed first.

    Some replies skip the queue. Words that suggest an emergency, such as chest pain or thoughts of self-harm, trigger a fixed, clinician-approved message with emergency instructions and an alert to staff; the model never writes that reply.

    What goes wrong in SMS intake projects?

    Most failures come from treating the model as the product instead of one step in a regulated workflow.

    • Missing agreement: one service in the chain, often logging or analytics, receives replies without a BAA.
    • Lost opt-outs: STOP handled in one tool while a second system keeps sending reminders.
    • Reassigned numbers: intake sent to a number that now belongs to someone else, with no confirmation step.
    • Silent guesses: the model fills a medication field the patient never mentioned, and nobody sees the source quote.
    • Direct writes: extracted data posted to the EHR before review, then hard to correct.
    • Open chat: the model starts answering clinical questions because the prompt allowed free replies.

    A worked example: new-patient intake for an orthopedic clinic

    An orthopedic clinic wants intake done before new-patient visits. Two days before each visit, the intake service checks the consent flag and texts the patient, asking for a YES reply to confirm the number is theirs.

    After YES, it asks five short questions: which joint, since when, what makes it worse, current medications and allergies. One patient answers "left knee since march, stairs, ibuprofen, no allergies" in a single text, so the model fills five fields and the service skips ahead.

    A medical assistant sees the draft with each source phrase, turns "since march" into a start date and approves it. The intake service writes a QuestionnaireResponse to the appointment, and the medication waits for the clinician to reconcile at the visit.

    Who owns each part of an SMS intake pipeline?

    An intake pipeline crosses clinical, technical and compliance teams, so each part needs a named owner.

    • Clinical lead: the question set, the emergency wording and what reviewers may change.
    • Engineering lead: the intake service, webhooks, schema, validation and EHR interface.
    • Compliance officer: BAAs with each vendor, consent language and the texting policy.
    • Intake manager: the review queue, its daily coverage and patient callbacks.

    How do you test and measure an SMS intake flow?

    Test with scripted conversations before any patient sees the flow, then measure the live system every week. The scripts should include short, misspelled, off-topic and hostile replies, not only clean ones.

    • Extraction accuracy: share of fields the reviewer did not change, tracked per field.
    • Completion rate: share of started intakes finished before the visit.
    • Opt-out handling: every listed keyword and several free-text refusals tested on each release.
    • Review time: time from a finished intake to approval.
    • Escalations: every emergency flag checked to confirm staff were alerted.

    Rerun the full script set whenever you change the prompt, the model version or the question list.

    What are SMS patient intake best practices?

    Sign a BAA with every service that touches replies, confirm the number before asking anything, and keep diagnoses and results out of the message body. Record consent and enforce opt-outs in the send path itself.

    Use the model only to extract into a fixed schema with source quotes, validate in code, and have staff approve each intake before it is written to the EHR through its supported interfaces.

    How can Agnotic help build SMS patient intake?

    Agnotic designs and builds SMS intake pipelines for clinics and digital health teams: Twilio messaging, consent and opt-out logic, model extraction with a fixed schema, review screens and EHR write-back over HL7 FHIR or HL7 v2. We work through the vendor agreements with your compliance team and test the flow with scripted conversations before launch.

    Build patient intake by text with Agnotic

    We build messaging, extraction, review and EHR write-back as one tested workflow.

    Sources

    Frequently Asked Questions

    Yes, through the OpenAI API after your organization accepts OpenAI's BAA. Staff should not paste patient texts into a separate ChatGPT workspace, which sits outside the pipeline and its controls.

    Talk to an engineer about your project

    Tell us your intake questions and your EHR. We will map the messaging, extraction and review steps for your clinic.

    Go deeper

    Services and solutions on this topic