Building Gorgi: a one-line grounded AI chat widget for websites

Audio version

2:51

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:

  1. A business creates a site.
  2. It adds a knowledge source.
  3. It embeds one script tag.
  4. A visitor asks a question.
  5. 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:

  1. Validate the site and origin.
  2. Check quotas before any billable AI call.
  3. Retrieve tenant-scoped chunks.
  4. Generate a short grounded answer.
  5. 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.

  • Edge Form

    A self-hostable Cloudflare Workers contact form backend with D1 persistence, spam checks, delivery adapters, and CSV export.

  • Flare Control

    A Cloudflare-native platform for orchestrating AI agents with human-in-the-loop controls.

  • Gorgi - Site Widget Assistant

    A one-line-to-embed AI support widget that answers from a website's own content.

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

All posts