← Blog

API-based AI support: integrating an assistant into your own product

Engineering8 min read

Most AI support tools ship a script tag that renders a chat bubble. For a lot of sites that is exactly right, and the integration takes a minute.

It stops being right when the assistant needs to live inside your own interface: a native mobile app, an authenticated dashboard with its own design system, an existing helpdesk where answers should arrive as draft replies rather than a separate chat. That is an API integration, and this covers what one involves.

When the widget is the wrong shape

  • Native mobile, where an embedded web view is a poor experience
  • An authenticated product surface with its own component library
  • Agent assist — answers proposed to a human rather than sent to a customer
  • Non-web channels: email autoresponders, internal Slack, voice
  • Any flow where the assistant is one step in a larger process rather than the whole interaction

The shape of the contract

A chat endpoint is a small API with a few non-obvious requirements. It is stateless per request but conversational in effect, so the client supplies continuity.

You send a tenant credential, a stable visitor identifier, the message, and optionally a conversation ID and recent history. You get back the answer, whether it was actually answered, citations, and the conversation ID to use next time.

Request

POST /api/widget/chat
Content-Type: application/json

{
  "key": "your_public_key",
  "visitor_id": "stable-per-user-id",
  "conversation_id": "returned-from-previous-turn",
  "message": "Where is my order 1042?",
  "history": [
    { "role": "user", "content": "…" },
    { "role": "assistant", "content": "…" }
  ]
}

Response

{
  "conversation_id": "…",
  "answer": "…",
  "answered": true,
  "offer_support": false,
  "citations": [{ "label": "Shipping policy", "url": "https://…" }],
  "message_id": "…"
}

Use the answered flag — it is the point

The field worth building around is not the answer text; it is whether the assistant considers the question answered. That boolean is what lets your interface behave sensibly rather than displaying every response identically.

In an agent-assist integration, a low-confidence answer should be presented as a draft for review rather than a suggestion to send. In a customer-facing one, an unanswered response should surface your escalation path immediately. Ignoring the flag and rendering all answers the same way discards the most useful thing the API tells you.

Identity, if the assistant can see customer data

In your own authenticated product the temptation is to pass the logged-in user's ID and be done. Resist it if that ID unlocks data lookups: your client is still a client, and a client-supplied identifier is a claim.

The correct pattern is the same as for the widget — your server signs a token asserting who the user is, and the assistant verifies that signature before offering any tool that reads customer data. It is a small amount of work that turns an authorisation decision from trust into proof.

What your integration has to handle

  • Rate limits — expect them per visitor and per tenant, and degrade gracefully rather than erroring
  • Conversation length caps — plan for the API telling you to start a new thread mid-flow
  • Latency — a tool call means two model round trips; show progress rather than a frozen input
  • Citations — render them, or you have removed the reader's ability to verify anything
  • Failures — a 500 should produce a fallback message and your escalation path, not a stack trace

Server-side truth still matters

One thing an API integration should not do is become the only record of what happened. Conversations, confidence, citations, and unanswered questions should still land in the assistant's own store, because that is where the improvement loop lives.

If your integration silently discards unanswered questions, you lose the queue that tells you what content to write — which is the mechanism by which the whole system gets better over time.

An API integration is the right call whenever the assistant belongs inside an interface you control. Build around the answered flag, prove identity server-side, and keep the failure record flowing back to the place that can act on it. AskBrew exposes the same endpoint its own widget uses, so the widget is a reference implementation rather than a privileged client.

Try it on your own content

Free to start — live in minutes.

Get started

Keep reading

Comparison

AskBrew vs Chatbase: which fits your support team?

Both build a chatbot from your own content. They differ in what happens when the assistant is unsure, and in whether it can answer questions about a specific customer's account.

Buyer's guide

Chatbase alternatives: how to actually choose one

A buyer's guide to the AI support chatbot category — the four questions that separate these tools, and which type of alternative fits which situation.

Buyer's guide

Best AI customer support software: a buyer's guide for 2026

What AI support tools actually do, the three categories they fall into, and how to evaluate them without relying on vendor feature tables.

Engineering

Multi-tenant RAG: keeping one customer's data out of another's answers

Vector search across shared infrastructure has a failure mode worse than a bad answer. How to make tenant isolation a property of the database rather than a discipline.

Engineering

Function calling for support bots

Letting an assistant look up a customer's order turns a content bot into something useful — and introduces an authorisation problem that must be solved outside the model.

Engineering

How to build an AI support agent

A build guide for the whole system: ingestion, retrieval, the answer gate, tool calls, and the operational pieces tutorials leave out.

Engineering

Preventing hallucinations in customer support bots

Grounding reduces fabrication but does not eliminate it. The techniques that actually work, and why an assistant that refuses is more valuable than one that always answers.

Engineering

pgvector vs Pinecone: choosing a vector store

A dedicated vector database and a Postgres extension solve the same problem differently. The deciding factor is usually not search performance.

Engineering

RAG architecture explained, for people shipping it

The components of a retrieval-augmented generation system, the decisions that actually affect answer quality, and where production implementations diverge from tutorials.

Engineering

How AI customer support actually works

What happens between a customer typing a question and an answer appearing: retrieval, grounding, confidence, and the decision to answer or hand over.