System flow
The whole bot on one whiteboard: how a question becomes a cited answer or a booking, how a clinic's PDF becomes searchable knowledge, and what each piece of the stack does.
Where patients talk to it
Web chat
The chat on the Try it page.
Live in this demoTelegram
Not live in this demo. Plugs into the same core: same answers, bookings and guardrails.
Planned channel1. A patient asks a question
This is RAG with tools. The bot retrieves the clinic's own text first, so the AI answers from facts, not from memory.
Patient asks
"How much is a consultation?"
Web chatGuardrail
Symptoms or medicines? Straight to staff. The AI never sees it.
Worker codeEmbed the question
Text becomes a vector (a list of numbers that captures meaning).
Embeddings modelVector search
Find the 4 closest passages from the clinic's PDF. Weak matches dropped.
Neon pgvectorLLM + passages
The AI only sees those passages and the clinic's facts, and must cite them.
Neon AI GatewayTool calls
get_price · find_slots · book_slot · handoff. Real data, real bookings.
Cloudflare D1Checks, then reply
Price not on the list? Blocked. Every message gets a reply or a person.
Worker code= Retrieval (find the right passages) + Augmented (give them to the AI) + Generation (the AI writes the answer, citing them).
2. A clinic teaches it (ingestion)
Done once per clinic, in about a minute. This is what makes retrieval possible.
Clinic uploads a PDF
Services, prices, doctors, schedules, HMOs, policies.
Cloudflare R2Workflow runs
Extract text → split into ~180-word chunks.
n8nEmbed every chunk
Each chunk becomes a vector and is stored for search.
Neon pgvectorPull out the facts
The AI fills a fixed form (structured output), validated before saving.
LLM + ZodHuman review
A person checks the facts and publishes. Slots are made from schedules.
Cloudflare D13. A patient sends a photo (vision)
HMO cards and lab requests are read by a vision model, then checked by code.
Patient sends a photo
HMO card or lab request.
Cloudflare R2Vision model reads it
What it is, the fields, how sure it is, as fixed JSON.
Vision LLMCode writes the reply
Prices from the list, member ID masked. Prescription or unsure? Staff.
Worker codeTech stack
- Cloudflare Workers + Hono · runs the bot, no servers
- Cloudflare D1 (SQL) · clinic data; a slot books once
- Cloudflare R2 · PDFs and photos
- Neon Postgres + pgvector · the vector database for RAG
- Neon AI Gateway · LLM, vision, embeddings; swappable
- n8n · the ingestion workflow
- TypeScript · Zod · Vitest · typed, validated, 60 tests
Words on this board
- RAG · Retrieval-Augmented Generation: look up the right passages first, then let the AI answer from them
- Embeddings · text turned into vectors so "check-up" can match "consultation"
- Vector database · stores those vectors and finds the closest ones fast
- Tool calling · the AI asks the code to do things (check a price, book a slot)
- Guardrails · rules in code the AI cannot talk its way around
- Human in the loop · a person reviews facts and takes over when the bot is unsure
Swap the documents, keep the engine
- The engine · upload, chunk, embed, retrieve, cite, guardrails, handoff, vision. Domain-free.
- The clinic skin · the facts form and the price and booking tools.
- Law firm · answers from engagement terms, books consultations, flags legal advice for a lawyer.
- Hardware store · answers from product manuals, checks stock and prices.
- HR or support · answers from handbooks and SOPs, opens a ticket for a person.
Try the botComing next: demo limits, voice notes, an n8n back office and a scored test set.