Building Gorgi: a one-line grounded AI chat widget for websites
Listen while you read
A website chatbot is easy to demo and hard to trust. The useful version has to answer from the business’s own content, avoid leaking data between tenants, keep costs predictable, and embed without breaking the host page.
That is the shape behind Gorgi: a one-line AI chat widget built on Cloudflare’s edge.
The smallest complete loop
The MVP loop is intentionally small:
- A business creates a site.
- It adds a knowledge source.
- It embeds one script tag.
- A visitor asks a question.
- The answer is grounded in that site’s content.
Anything beyond that had to justify itself.
The request pipeline matters
The public chat route follows a strict order:
- Validate the site and origin.
- Check quotas before any billable AI call.
- Retrieve tenant-scoped chunks.
- Generate a short grounded answer.
- Return escaped text, never raw HTML.
That order is the product. If quota checks happen after retrieval or generation, cost controls are not real. If tenant filtering is optional, isolation is not real.
Embeddable means boring on purpose
The widget is dependency-free TypeScript rendered inside a Shadow DOM. That keeps it isolated from the host page’s CSS and JavaScript assumptions. It also keeps the payload small, which matters because the widget runs on someone else’s site.
The dashboard can use React. The embed should not need it.
Why Cloudflare fit
Workers keep the public API close to users. D1 stores metadata, customers, configuration, and usage counters. Workers AI handles generation. Cloudflare AI Search handles managed retrieval and metadata filtering.
The result is a full product loop without a large backend footprint.
What this proves
Gorgi is a practical AI product case study, not just a chat UI. It shows product scope, AI cost control, tenant isolation, frontend isolation, and edge-native API design.
If you need a grounded AI feature or a product prototype, start here.
Need help with something like this?
Send the product goal, timeline, and current blockers. I’ll help you find the smallest useful next step.
Start a conversation