Demo by interpt
/diagnostic
live at interpt.co/diagnostic

How the diagnostic works

A sample run with an invented prospect. On the left, what the visitor sees. On the right, what happens on the server for each answer.

visitor

step 1 of 17

server

Cloudflare Pages Functions
Architecture of the diagnostic The browser talks to a Cloudflare Pages Function, which checks Turnstile, keeps sessions and leads in D1, asks the rules engine for the recommendation, calls Claude Haiku for wording and question choice, and sends the lead to the CRM with two emails. Browserthe visitor Turnstilebot check Pages Function/api/diagnostic/* D1sessions, leads Rules enginepicks the service Claude Haikuasks, reads, writes CRM + emaillead, two emails

Click a box to see what it does.

/what the model can and cannot do

The rules decide, the model words it

A plain rules engine picks the service, the secondary service and the lead class from the answers. Haiku gets that decision as fixed input and is told it cannot change it. It writes the explanation and nothing else.

Visitor text is data

Free text goes to the model inside tags and the system prompt says never to follow instructions found in it. Before that, keys, tokens, connection strings, emails and phone numbers are stripped out.

Answers come back as a schema

Every call uses structured output with enums. Choosing the next question can only return one of the five candidates the rules allowed, or "finish". Anything else is ignored.

A filter before the visitor sees it

The final text is checked for prices, guarantees and certification claims. If one slips in, or the call times out, the visitor gets the rules-engine version instead and the lead is flagged for review.

Bots and costs are capped

Turnstile runs on start and on submit. D1 keeps per-IP limits, a per-address limit on emails and a daily cap on AI calls, so a flood of traffic cannot run up the bill.

The lead is saved first

The lead goes into D1 before the AI call. If the CRM is down, later requests retry the sync, so nobody who finished the diagnostic gets lost.

Sample run: the prospect, the clinic and the answers are invented. The questions, rules and result format are the ones the live diagnostic uses. Run the real one.