Back to all articles
AI Automation May 15, 2026 8 min read

How I Built an AI Support Bot in 4 Days

#ai#shopify#automation
How I Built an AI Support Bot in 4 Days

Most Shopify support tickets are the same 50 questions, asked in slightly different ways. "Where's my order?" "How do I return this?" "What's your sizing chart?" If your team is drowning in those, an AI bot trained on your knowledge base can handle 60–80% of them without breaking a sweat.

Here's how I built one for a store in 4 days, and exactly how the pieces fit together.

The architecture

The bot has three moving parts:

  1. Frontend widget — a tiny React island injected via a single <script> tag. Around 8 KB gzipped, lazy-loaded, no impact on store performance.
  2. Edge API — a Next.js route on Vercel Edge that wraps OpenAI's chat completions endpoint. Adds rate limiting, request shaping, and logging.
  3. Knowledge base — a small Postgres table (Supabase) seeded with the store's FAQs, policies, and product info. Retrieval happens at query time via embeddings.

That's it. No LangChain, no vector DB service, no orchestration framework. Just three files and a database.

Why so simple?

Every layer of abstraction costs you debuggability. When the bot says something wrong on day 7, you need to be able to read your own code in 60 seconds and find the bug. Big AI frameworks turn that 60 seconds into 60 minutes.

Ship small. Iterate fast. Add complexity only when a real customer problem demands it.

The prompt

The system prompt is the single highest-leverage thing in the whole system. Here's the rough shape:

You are a customer support assistant for {STORE_NAME}.

Use ONLY the context below to answer. If the answer isn't in the context,
say "Let me connect you with a human" and end the conversation.

Tone: friendly, concise, like a helpful store employee.
Never invent shipping times, prices, or policies.

Context:
{RETRIEVED_FAQS}

The two non-obvious lines: "Use ONLY the context" and "Never invent." These two constraints prevent 90% of hallucinations. The bot would rather hand off to a human than guess.

Results after week one

  • 1,247 messages handled
  • 71% resolved without a human
  • 18 hours/week saved on the support team
  • 4 escalations to humans for genuinely novel issues

The store owner messaged me: "I don't know why we waited so long."

What I'd do differently next time

  • Add a feedback thumbs-up/down on every reply from day one. I added it in week two and the data is gold.
  • Log every "Let me connect you with a human" message — those are the gaps in your knowledge base.
  • Don't bother with a fancy admin UI in v1. A Postgres table and a CSV upload script is enough.

If you want a bot like this, book a call. 14-day delivery, fixed price, you own the code.

Ghulam Mustafa

Ghulam Mustafa

Full-Stack AI & Shopify Engineer

Ready to automate your business?

Book a free 30-minute call. Walk away with at least one actionable insight — even if we never work together.