Build a customer support bot
An avatar that answers from your help documentation and hands transcripts back for review.
This walkthrough builds a support avatar end to end: pick a face, give it your help documentation, shape how it behaves, put it in front of users, and read back what it said.
Budget about 30 minutes. You need an API key — see Authentication.
Every request needs your API key. Set it once:
export GOLDENENGINE_API_KEY="<YOUR_API_KEY>"
1. Pick an avatar
A stock avatar is the quickest starting point: it is ready immediately. Its persona is fixed, though — step 4 covers what that rules out — so a bot confined to your documentation eventually means an avatar you own. The other steps work with either, with one difference in step 3.
- cURL
- Python
- Node.js
curl -s "https://backend.goldenengine.ai/v1/avatars/stock" \
-H "X-Api-Key: $GOLDENENGINE_API_KEY"
import os
import requests
BASE = "https://backend.goldenengine.ai"
HEADERS = {"X-Api-Key": os.environ["GOLDENENGINE_API_KEY"]}
stock = requests.get(f"{BASE}/v1/avatars/stock", headers=HEADERS).json()
ready = [a for a in stock["items"] if a["status"] == "ready"]
avatar_id = ready[0]["id"]
const BASE = "https://backend.goldenengine.ai";
const headers = { "X-Api-Key": process.env.GOLDENENGINE_API_KEY };
const stock = await (
await fetch(`${BASE}/v1/avatars/stock`, { headers })
).json();
const ready = stock.items.filter((a) => a.status === "ready");
const avatarId = ready[0].id;
Pick one whose status is ready and keep its id:
export AVATAR_ID="<id from the response>"
2. Upload your help documentation
Attach your support material directly to the avatar. PDF and DOCX, up to 50 MB per file, and up to five files in one request:
- cURL
- Python
- Node.js
curl -s "https://backend.goldenengine.ai/v1/avatars/$AVATAR_ID/knowledge/batch" \
-H "X-Api-Key: $GOLDENENGINE_API_KEY" \
names = ["help-center.pdf", "refund-policy.pdf", "troubleshooting.pdf"]
documents = [open(name, "rb") for name in names]
try:
batch = requests.post(
f"{BASE}/v1/avatars/{avatar_id}/knowledge/batch",
headers=HEADERS,
files=[("files", document) for document in documents],
).json()
finally:
for document in documents:
document.close()
for result in batch["results"]:
if result.get("error"):
print(result["filename"], result["error"]["code"], result["error"]["message"])
import { readFile } from "node:fs/promises";
const form = new FormData();
for (const name of ["help-center.pdf", "refund-policy.pdf", "troubleshooting.pdf"]) {
form.append("files", new Blob([await readFile(name)], { type: "application/pdf" }), name);
}
const batch = await (
await fetch(`${BASE}/v1/avatars/${avatarId}/knowledge/batch`, {
method: "POST",
headers,
body: form,
})
).json();
for (const result of batch.results) {
if (result.error) console.log(result.filename, result.error.code, result.error.message);
}
A 201 means all three were queued. If any file fails validation — wrong type, empty,
over 50 MB — the whole request is rejected with 400 and nothing is queued; the message
names the file. A 207 is different: every file was valid, but at least one could not be
stored or queued on our side (upload_failed or queue_unavailable in results, which
come back in the order you sent them). Nothing is wrong with that file — re-send it on its
own; the others are already processing.
Extraction is asynchronous. Wait for everything to reach completed:
- cURL
- Python
- Node.js
curl -s "https://backend.goldenengine.ai/v1/avatars/$AVATAR_ID/knowledge" \
-H "X-Api-Key: $GOLDENENGINE_API_KEY"
docs = requests.get(
f"{BASE}/v1/avatars/{avatar_id}/knowledge", headers=HEADERS
).json()
for item in docs:
print(item["filename"], item["status"], item.get("chunk_count"))
const docs = await (
await fetch(`${BASE}/v1/avatars/${avatarId}/knowledge`, { headers })
).json();
for (const item of docs) {
console.log(item.filename, item.status, item.chunk_count);
}
3. Verify retrieval before going live
Search the knowledge directly, using questions your users actually ask. This isolates retrieval from the model.
- cURL
- Python
- Node.js
curl -s "https://backend.goldenengine.ai/v1/knowledge-bank/search" \
-H "X-Api-Key: $GOLDENENGINE_API_KEY" \
-H "Content-Type: application/json" \
-d '{"query": "how long do refunds take", "limit": 5}'
hits = requests.post(
f"{BASE}/v1/knowledge-bank/search",
headers=HEADERS,
json={"query": "how long do refunds take", "limit": 5},
).json()
for chunk in hits["chunks"]:
print(chunk["filename"], chunk.get("page_number"), chunk["content"][:120])
const hits = await (
await fetch(`${BASE}/v1/knowledge-bank/search`, {
method: "POST",
headers: { ...headers, "Content-Type": "application/json" },
body: JSON.stringify({ query: "how long do refunds take", limit: 5 }),
})
).json();
for (const chunk of hits.chunks) {
console.log(chunk.filename, chunk.page_number, chunk.content.slice(0, 120));
}
Empty or irrelevant results here will be empty or irrelevant in conversation too. Fix the documents now — it is much harder to diagnose once a language model is in the loop.
POST /v1/knowledge-bank/search covers your account-level documents, and that is where
documents uploaded to a stock avatar are stored — so everything from step 2 is in scope.
They stay in your account bank but answer only for the stock avatars you attached them to.
Documents attached to an avatar you own are not searched; for those, list
GET /v1/avatars/{avatar_id}/knowledge to confirm each document is there, completed, and
has a sensible chunk_count, then test with a real conversation.
4. Shape the behavior
A support avatar needs tighter behavior than a general one: stay on topic, answer from the documentation, and hand off rather than guess. You do not write its system prompt — the API generates it from the avatar's persona fields — so you shape it through those fields, plus one switch.
- cURL
- Python
- Node.js
curl -s -X PATCH "https://backend.goldenengine.ai/v1/avatars/$AVATAR_ID" \
-H "X-Api-Key: $GOLDENENGINE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"bio": "Support agent for Acme. Helps customers with orders, refunds, and account questions in two or three sentences, and offers to connect them with a human whenever the documentation does not cover the question.",
"interaction_guardrails": [
"Stay on topic",
"Base answers only on provided material",
"Keep responses professional"
],
"web_search_enabled": false
}'
BIO = (
"Support agent for Acme. Helps customers with orders, refunds, and account questions in two or three sentences, and offers to connect them with a human whenever the documentation does not cover the question."
)
updated = requests.patch(
f"{BASE}/v1/avatars/{avatar_id}",
headers=HEADERS,
json={
"bio": BIO,
"interaction_guardrails": [
"Stay on topic",
"Base answers only on provided material",
"Keep responses professional",
],
"web_search_enabled": False,
},
)
updated.raise_for_status()
const bio =
"Support agent for Acme. Helps customers with orders, refunds, and account questions in two or three sentences, and offers to connect them with a human whenever the documentation does not cover the question.";
const updated = await fetch(`${BASE}/v1/avatars/${avatarId}`, {
method: "PATCH",
headers: { ...headers, "Content-Type": "application/json" },
body: JSON.stringify({
bio,
interaction_guardrails: [
"Stay on topic",
"Base answers only on provided material",
"Keep responses professional",
],
web_search_enabled: false,
}),
});
if (!updated.ok) throw new Error(`PATCH failed: ${updated.status}`);
web_search_enabled is on by default: an avatar can look things up on the web when a
question needs current facts. For a bot that should answer only from your documentation,
turn it off — otherwise a question your documents do not cover may get an answer from the
web instead of a hand-off.
interaction_guardrails come from a fixed list; the accepted values are on the request
body in the API reference. They are written into the prompt as guidance, not
enforced separately. Enforcement is the job of the
response guardrail, which checks every sentence before it
is spoken: for a support bot, set guardrail_fallback_line to a hand-off ("I can't help with
that here — I'll connect you with the team.") and put competitor names or promises you never
make in guardrail_blocked_words.
The bio is free text, so it is where the rest goes:
- Length. Spoken answers run long. A paragraph that reads fine takes 30 seconds to hear.
- Escalation. Say what the avatar should do when the documentation does not cover the question. Without that, models tend to produce a plausible answer rather than admitting the gap — which is exactly the failure mode that costs you trust.
Changing any persona field (name, bio, awards_achievements, known_for,
personality_traits, interaction_guardrails) regenerates the prompt through a model call,
so the request can return 502; retry it. Lists replace the current value rather than adding
to it, and so does knowledge_base_ids — send the complete set of documents you want the
avatar to keep. system_prompt itself is read-only: sending it returns 422.
5. Start sessions from your support page
Create the conversation when the user clicks to start — not on page load, since the session token expires after 60 minutes.
- cURL
- Python
- Node.js
curl -s "https://backend.goldenengine.ai/v1/conversations" \
-H "X-Api-Key: $GOLDENENGINE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"avatar_id": "'"$AVATAR_ID"'",
"end_user_id": "cust-42",
"title": "Support — web widget",
"greeting": "Hi! I can help with orders, refunds, and account questions. What do you need?"
}'
customer_id = "cust-42" # the customer's ID in your own system
conversation = requests.post(
f"{BASE}/v1/conversations",
headers=HEADERS,
json={
"avatar_id": avatar_id,
"end_user_id": customer_id,
"title": "Support — web widget",
"greeting": "Hi! I can help with orders, refunds, and account questions. What do you need?",
},
).json()
const customerId = "cust-42"; // the customer's ID in your own system
const conversation = await (
await fetch(`${BASE}/v1/conversations`, {
method: "POST",
headers: { ...headers, "Content-Type": "application/json" },
body: JSON.stringify({
avatar_id: avatarId,
end_user_id: customerId,
title: "Support — web widget",
greeting: "Hi! I can help with orders, refunds, and account questions. What do you need?",
}),
})
).json();
The avatar must be ready: one that is still training, or that your key cannot use, returns
404. The response carries conversation_id and conversation_url. Keep the ID; step 6
uses it:
export CONVERSATION_ID="<conversation_id from the response>"
A specific greeting outperforms a generic one. Naming what the avatar can help with steers users toward questions your documentation actually answers.
end_user_id is the customer's ID in your own system. It gives each customer a memory of
their own: the avatar starts their next session knowing what came before — written shortly
after the previous session ended, so one that starts immediately may not see it yet — and
never carries one customer's details into another's. For a visitor you cannot identify, leave it out and
the session gets isolated memory. See
Memory and end users.
Memory is kept per avatar, too: switch the bot to a different avatar and every customer starts with an empty memory. Two memory calls are worth wiring into a support bot — see Memory for both:
- Forget a customer. When a customer asks you to delete their data,
DELETE /v1/avatars/{avatar_id}/memory?end_user_id=cust-42removes what the avatar remembers about them. Their conversations and transcripts stay —DELETE /v1/conversations/{conversation_id}removes those. - Tell it what you already know. A
pinned memory —
POST /v1/avatars/{avatar_id}/memory/pinned— hands the avatar a fact from your own records, such as the customer's plan, before their first conversation.
Render the returned conversation_url in an iframe on your support page — see
Embed an avatar for the iframe attributes and the
click-to-start pattern.
6. Review transcripts
Every conversation is recorded and readable afterwards — this is your feedback loop.
- cURL
- Python
- Node.js
curl -s "https://backend.goldenengine.ai/v1/conversations?limit=50" \
-H "X-Api-Key: $GOLDENENGINE_API_KEY"
curl -s "https://backend.goldenengine.ai/v1/conversations/$CONVERSATION_ID/transcript" \
-H "X-Api-Key: $GOLDENENGINE_API_KEY"
recent = requests.get(
f"{BASE}/v1/conversations", headers=HEADERS, params={"limit": 50}
).json()
for item in recent["items"]:
transcript = requests.get(
f"{BASE}/v1/conversations/{item['id']}/transcript", headers=HEADERS
).json()
print(item["title"], transcript)
const recent = await (
await fetch(`${BASE}/v1/conversations?limit=50`, { headers })
).json();
for (const item of recent.items) {
const transcript = await (
await fetch(`${BASE}/v1/conversations/${item.id}/transcript`, { headers })
).json();
console.log(item.title, transcript);
}
To pull one customer's history, add end_user_id to the list call:
GET /v1/conversations?end_user_id=cust-42.
Read transcripts weekly and look for two patterns. Questions the avatar could not answer are
gaps in your documentation — the fix is a new document, not a prompt change. Questions it
answered wrongly are usually retrieval problems; run them through
POST /v1/knowledge-bank/search to see what it was working from. That covers documents on
a stock avatar or your account; for an avatar you own, check
GET /v1/avatars/{avatar_id}/knowledge instead — search does not reach its documents.