
AI WORKFLOW DEVELOPMENT / HEALTHCARE
An architecture and development case study

The challenge
A mental-health practice wanted to bring supportive conversation into text messaging and turn incoming fax documents into structured information for its administrative workflow. Each idea depended on something less visible than the AI response: a reliable connection to the systems around it.
For messaging, the application needed to connect a sender to the right conversation context and return a readable reply. For documents, it needed a path from an uploaded file to analysis and stored information. These became two connected development workstreams with different operational demands.
The approach
The architecture separated the communication channel, application logic, AI processing and storage. This gave each part a clear job and made the handoffs explicit: receive an input, locate the right context, process it, and send or store the result.

What was developed
SMS conversation flow
The TypeScript implementation linked a sending phone number to an OpenAI conversation thread. It reused an existing thread identifier or created and stored a new one, submitted the incoming message, retrieved the AI response, and passed the reply to TextGrid. Formatting cleanup and message splitting addressed the practical constraints of SMS.
Document analysis and persistence
The documented intake path used a form upload and webhook to pass a file link to the application. The code included document-analysis routes and Supabase utilities for saving extracted information, document links, categories and analysis status. Conversation mapping stored a phone number and thread identifier rather than a copy of the full conversation history.
Designing for the channel
Conversation design was part of the development work. The prompt requirements called for brief, empathetic responses, permission before offering suggestions, and one suggestion at a time. They also described professional boundaries and referrals to care resources. These were intended behaviors to evaluate, rather than established clinical capabilities.
The integration lessons
Keep context explicit
A useful conversation depends on knowing which thread a message belongs to. Making the phone-to-thread relationship explicit gave the application a defined way to continue a conversation across messages.
Follow the whole document path
Document analysis has to connect to intake and storage. The design linked file submission, webhook delivery, analysis and persistence, making the work between those steps visible.
Treat vendor dependencies as delivery work
Progress notes described the application as nearly ready, followed by unresolved phone-number porting and fax-data flow problems. That sequence illustrates why an implementation milestone and operational readiness need separate checks. Channel delivery and downstream data movement belong in the test plan alongside AI output quality.
Scope of this case study
This case documents architecture, conversation requirements and developed code paths. The available record does not verify a production launch, reliable end-to-end operation, clinical effectiveness, time savings, financial returns or regulatory compliance.
Have a workflow that needs a clearer path?
Start with the channel people use, the context each step needs, and where the result must go. To explore a practical AI workflow for your organization, start a conversation at thejasonfleagle.com.


