Build a help-desk agent from documents and a spreadsheet
What you'll build: the help desk of an outdoor-gear web shop. It answers "can I return a used tent?" by searching the shop's policy files, and "how many orders are still waiting to ship?" by running SQL on a CSV of 120 orders. AcruxCore runs the whole agent: the model calls, the search, the SQL and the loop between them. Your code sends a question and gets the answer back.
The two questions need two kinds of knowledge base. A policy answer sits in one paragraph, so
a search that returns the closest passages finds it. A count needs every row of the orders,
and a search returns only a few passages, so the orders go in a tables base that the
model queries with one SQL SELECT. Each base you attach to the agent becomes one tool the
model can call.
scripts/tutorials/build-a-help-desk-agent/— the data, plus a setup, an ask and a teardown script inbash/(curl),python/andtypescript/
Before you start
You need an AcruxCore account, an API key, and two models registered under
Gateway → Models: a chat model and an embedding model. This page uses an OpenAI
credential with the public names gpt-4o-mini and text-embedding-3-small.
Route calls through the gateway shows how to
add a credential and register a model.
- Dashboard
- curl
- Python
- Node
Nothing to install. Download the
data folder,
because step 1 copies the prompt from it and step 5 uploads its files.
export ACRUXCORE_API_KEY=acx_sk_...
export ACRUXCORE_BASE_URL=https://api.acruxcore.com/api/v1 # or your own host
cd scripts/tutorials/build-a-help-desk-agent/data
The curl examples use jq to build JSON bodies and read
ids out of responses.
pip install acruxcore
export ACRUXCORE_API_KEY=acx_sk_...
export ACRUXCORE_BASE_URL=https://api.acruxcore.com/api/v1 # or your own host
import asyncio
from pathlib import Path
from acruxcore import AcruxCore
DATA = Path("scripts/tutorials/build-a-help-desk-agent/data")
async with AcruxCore() as hub: # reads the two environment variables above
# Agents and knowledge bases take a model id; look it up by the name the dashboard shows.
model_ids = {m.public_name: m.id for m in await hub.models.list()}
... # every Python snippet below runs inside this block
npm install @acruxcoreai/sdk
export ACRUXCORE_API_KEY=acx_sk_...
export ACRUXCORE_BASE_URL=https://api.acruxcore.com/api/v1 # or your own host
import { readdir, readFile } from 'node:fs/promises';
import { setTimeout as sleep } from 'node:timers/promises';
import { acruxcore } from '@acruxcoreai/sdk';
const DATA = new URL('./scripts/tutorials/build-a-help-desk-agent/data/', import.meta.url);
const hub = new acruxcore(); // reads the two environment variables above
// Agents and knowledge bases take a model id; look it up by the name the dashboard shows.
const models = await hub.models.list();
const modelId = (name) => {
const model = models.find((m) => m.publicName === name);
if (!model) throw new Error(`No gateway model named ${name}`);
return model.id;
};
How each step is shown
Steps 1 to 5 build the agent, and each one shows two routes in one set of tabs. Dashboard is the click path in the agent builder. curl, Python and Node do the same thing from code. Both routes call the same endpoints and store the same objects, so you can build the agent in the dashboard and run it from code, or the other way round.
In the dashboard you create both knowledge bases from the agent's page, while the agent is still unsaved. Code follows the same order: the bases first, then the agent, then the files.
The data
The data folder
holds three things:
policies/: four Markdown files,returns.md,shipping.md,warranty.mdandproduct-care.md. Each##heading starts one rule, such as "Used items" under "Returns".orders.csv: 120 orders, one row each, with the columnsorder_id,ordered_on,country,product,category,quantity,total_eur,status,shipped_onanddelivered_on. A status isprocessing,shipped,deliveredorreturned.system-prompt.txt: the agent's instructions, which step 1 stores as a prompt.
You are the help desk of an outdoor-gear web shop. Answer customers in a friendly, short way.
- For questions about returns, shipping, warranty or product care, search the shop policies and answer only from what you find. Quote the exact number of days, the percentage or the price.
- For questions about an order, or about counts and totals of orders, query the orders table with SQL. Never guess an order's status.
- If neither the policies nor the orders answer the question, say you do not know and offer to pass it to a colleague.
The prompt tells the model which tool fits which question. The model also reads each base's description, which steps 2 and 3 write, so the two texts should agree.
1. Write the system prompt
An agent follows a stored prompt, so its instructions are versioned like any other prompt.
The agent runs the version that the production alias points to, and the first version you
commit gets that alias.
- Dashboard
- curl
- Python
- Node
Open Prompts and click New prompt. Name it help-desk and click Create prompt.
Paste system-prompt.txt into the System message, then click Commit new version.

PROMPT_ID=$(curl -sS --fail-with-body -X POST "$ACRUXCORE_BASE_URL/prompts" \
-H "Authorization: Bearer $ACRUXCORE_API_KEY" -H 'Content-Type: application/json' \
-d '{"name": "help-desk"}' | jq -r .id)
# jq reads the prompt from the file, so the shell never has to quote it.
jq -n --rawfile system system-prompt.txt '{messages: [{role: "system", content: $system}]}' |
curl -sS --fail-with-body -X POST "$ACRUXCORE_BASE_URL/prompts/$PROMPT_ID/versions" \
-H "Authorization: Bearer $ACRUXCORE_API_KEY" -H 'Content-Type: application/json' -d @- |
jq -r '"version \(.versionNumber)"'
prompt = await hub.prompts.create("help-desk")
await hub.prompts.commit_version(
prompt.id, [{"role": "system", "content": (DATA / "system-prompt.txt").read_text()}]
)
const prompt = await hub.prompts.create({ name: 'help-desk' });
await hub.prompts.commitVersion(prompt.id, {
messages: [{ role: 'system', content: await readFile(new URL('system-prompt.txt', DATA), 'utf8') }],
});
2. Create the policies base
A documents base splits each file into chunks and stores an embedding of each chunk, so
a search can find the chunks closest in meaning to a question. The policies are short rules
under headings, so split them with Markdown headings: each chunk is then one whole rule,
with its headings in front, such as Returns > Used items.
- Dashboard
- curl
- Python
- Node
Open Agents and click New agent. Fill in the top of the form:
- Name:
Help desk - Description:
Answers customers from the shop policies and the orders table.Only your team sees it; the model does not. - Prompt:
help-desk. Alias then showsproduction (v1). - Model:
gpt-4o-mini
Leave the page open and unsaved. Under Knowledge, click Attach knowledge base. The dialog lists the bases that already exist in your team. Click New knowledge base to make one without leaving the agent:
- Kind: Documents
- Name:
Help desk policies. The model calls the base's toolsearch_help_desk_policies, after this name. - Description:
The shop's policies: returns and refunds, shipping and delivery times, warranty, and product care.The model reads this text to decide when to search. - Embedding model:
text-embedding-3-small - Chunking method: Markdown headings

Click Create. The base is created at once and attached to the agent as a card.
EMBED_MODEL_ID=$(curl -sS --fail-with-body "$ACRUXCORE_BASE_URL/gateway/models" \
-H "Authorization: Bearer $ACRUXCORE_API_KEY" |
jq -r '.[] | select(.publicName == "text-embedding-3-small") | .id')
POLICIES_ID=$(jq -n --arg model "$EMBED_MODEL_ID" '{
name: "Help desk policies", embeddingModelId: $model, chunkStrategy: "markdown",
description: "The shop'"'"'s policies: returns and refunds, shipping and delivery times, warranty, and product care."
}' | curl -sS --fail-with-body -X POST "$ACRUXCORE_BASE_URL/knowledge-bases" \
-H "Authorization: Bearer $ACRUXCORE_API_KEY" -H 'Content-Type: application/json' -d @- | jq -r .id)
policies = await hub.knowledge_bases.create(
"Help desk policies",
embedding_model_id=model_ids["text-embedding-3-small"],
chunk_strategy="markdown",
description="The shop's policies: returns and refunds, shipping and delivery times, warranty, and product care.",
)
const policies = await hub.knowledgeBases.create({
name: 'Help desk policies',
embeddingModelId: modelId('text-embedding-3-small'),
chunkStrategy: 'markdown',
description: "The shop's policies: returns and refunds, shipping and delivery times, warranty, and product care.",
});
3. Create the orders base
A tables base holds CSV files and Excel sheets as tables. It has no embedding model and
no chunks. The agent gets a SQL tool for it instead, which runs one SELECT on a read-only
copy of the tables and returns at most 200 rows.
- Dashboard
- curl
- Python
- Node
Click Attach knowledge base again, then New knowledge base:
- Kind: Tables
- Name:
Help desk orders. The tool is calledquery_help_desk_orders. - Description:
Every web-shop order since October: order id, order date, country, product, category, quantity, total in EUR, status (processing, shipped, delivered or returned), ship date and delivery date.The model reads this text, together with the table's columns and a few sample rows, to write its SQL.
Click Create. The agent now has two cards.
ORDERS_ID=$(jq -n '{
kind: "tables", name: "Help desk orders",
description: "Every web-shop order since October: order id, order date, country, product, category, quantity, total in EUR, status (processing, shipped, delivered or returned), ship date and delivery date."
}' | curl -sS --fail-with-body -X POST "$ACRUXCORE_BASE_URL/knowledge-bases" \
-H "Authorization: Bearer $ACRUXCORE_API_KEY" -H 'Content-Type: application/json' -d @- | jq -r .id)
orders = await hub.knowledge_bases.create(
"Help desk orders",
kind="tables",
description="Every web-shop order since October: order id, order date, country, product, category, "
"quantity, total in EUR, status (processing, shipped, delivered or returned), ship date and delivery date.",
)
const orders = await hub.knowledgeBases.create({
kind: 'tables',
name: 'Help desk orders',
description:
'Every web-shop order since October: order id, order date, country, product, category, quantity, total in EUR, status (processing, shipped, delivered or returned), ship date and delivery date.',
});
4. Save the agent
The agent ties the prompt, the model and both bases together. Each base's card also holds how this agent searches it. Another agent that attaches the same base keeps its own settings.
This agent searches the policies with Results to return set to 4, so each search gives
the model the four closest rules. Reranker and Decision model stay off for now.
Rerank and filter an agent's search results
turns them on.
- Dashboard
- curl
- Python
- Node
Set Results to return to 4 and click Create agent. The page reloads as the saved
agent. The Tools panel on the right lists search_help_desk_policies and
query_help_desk_orders.

CHAT_MODEL_ID=$(curl -sS --fail-with-body "$ACRUXCORE_BASE_URL/gateway/models" \
-H "Authorization: Bearer $ACRUXCORE_API_KEY" |
jq -r '.[] | select(.publicName == "gpt-4o-mini") | .id')
jq -n --arg prompt "$PROMPT_ID" --arg model "$CHAT_MODEL_ID" \
--arg policies "$POLICIES_ID" --arg orders "$ORDERS_ID" '{
name: "Help desk", promptId: $prompt, modelId: $model,
knowledgeBases: [{knowledgeBaseId: $policies, topK: 4}, {knowledgeBaseId: $orders}]
}' | curl -sS --fail-with-body -X POST "$ACRUXCORE_BASE_URL/agents" \
-H "Authorization: Bearer $ACRUXCORE_API_KEY" -H 'Content-Type: application/json' -d @- |
jq -c '[.knowledgeBases[].toolName]'
agent = await hub.agents.create(
"Help desk",
prompt_id=prompt.id,
model_id=model_ids["gpt-4o-mini"],
knowledge_bases=[
{"knowledge_base_id": policies.id, "top_k": 4},
{"knowledge_base_id": orders.id},
],
)
print([k.tool_name for k in agent.knowledge_bases])
const agent = await hub.agents.create({
name: 'Help desk',
promptId: prompt.id,
modelId: modelId('gpt-4o-mini'),
knowledgeBases: [{ knowledgeBaseId: policies.id, topK: 4 }, { knowledgeBaseId: orders.id }],
});
console.log(agent.knowledgeBases.map((k) => k.toolName));
Each code route prints the agent's two tool names, search_help_desk_policies and
query_help_desk_orders.
5. Add the files
The bases are attached but still empty. A CSV becomes a table as soon as its upload returns.
The policy files are chunked and embedded in the background, which takes a few seconds, and
each file's status changes from processing to ready.
- Dashboard
- curl
- Python
- Node
On the Help desk policies card, click Open base. Click Choose files and pick the four
files in policies/. When all four show Ready, type Can I return a tent I have used?
into Test a search and click Search. The first result is the "Used items" rule from
returns.md, which is what the agent will get for the same question.

Go back to the agent and click Open base on the Help desk orders card. Click
Choose files and pick orders.csv. The table orders appears with 120 rows and 10 columns. Try a
query runs one SELECT the same way the agent does:
SELECT status, count(*) AS orders
FROM orders
GROUP BY status
ORDER BY orders DESC

curl -sS --fail-with-body -X POST "$ACRUXCORE_BASE_URL/knowledge-bases/$ORDERS_ID/documents" \
-H "Authorization: Bearer $ACRUXCORE_API_KEY" -F files=@orders.csv | jq -r '.data[].filename'
curl -sS --fail-with-body -X POST "$ACRUXCORE_BASE_URL/knowledge-bases/$POLICIES_ID/documents" \
-H "Authorization: Bearer $ACRUXCORE_API_KEY" \
-F files=@policies/product-care.md -F files=@policies/returns.md \
-F files=@policies/shipping.md -F files=@policies/warranty.md | jq -r '.data[].filename'
# Wait until every policy file is ready.
until [ "$(curl -sS "$ACRUXCORE_BASE_URL/knowledge-bases/$POLICIES_ID/documents" \
-H "Authorization: Bearer $ACRUXCORE_API_KEY" | jq -r '[.data[].status] | unique | join(",")')" = ready ]; do
sleep 1
done
await hub.knowledge_bases.upload_files(orders.id, [DATA / "orders.csv"])
await hub.knowledge_bases.upload_files(policies.id, sorted((DATA / "policies").glob("*.md")))
while True: # wait until every policy file is ready
docs = await hub.knowledge_bases.list_documents(policies.id)
if failed := [d for d in docs if d.status == "failed"]:
raise SystemExit(f"{failed[0].filename} failed: {failed[0].error}")
if all(d.status == "ready" for d in docs):
break
await asyncio.sleep(1)
await hub.knowledgeBases.uploadFiles(orders.id, [{ filename: 'orders.csv', data: await readFile(new URL('orders.csv', DATA)) }]);
const files = (await readdir(new URL('policies/', DATA))).filter((f) => f.endsWith('.md'));
await hub.knowledgeBases.uploadFiles(
policies.id,
await Promise.all(files.map(async (f) => ({ filename: f, data: await readFile(new URL(`policies/${f}`, DATA)) }))),
);
for (;;) { // wait until every policy file is ready
const docs = await hub.knowledgeBases.listDocuments(policies.id);
const failed = docs.find((d) => d.status === 'failed');
if (failed) throw new Error(`${failed.filename} failed: ${failed.error}`);
if (docs.every((d) => d.status === 'ready')) break;
await sleep(1000);
}
The agent is ready. The setup scripts in the repository run steps 1 to 5 in one go.
6. Ask the agent
Ask three questions in one conversation: one about a policy, one about a single order, and one that needs counts. The first question starts the conversation. The next two pass its id, so the agent reads the earlier turns as history.
- Dashboard
- curl
- Python
- Node
On the agent's page, click Chat and send each question in turn:
I bought a Trail 2 tent three weeks ago and used it once. Can I still return it, and how much do I get back?
Where is my order 20401?
Which product category was returned most often, and how many orders are still waiting to ship?
Under each answer, Steps lists each tool call with its arguments and the start of its
result. For order 20401, the model wrote a SELECT on orders and answered from the row it
got back.

A run takes the agent's id or its name, percent-encoded. Without stream, the response is
the finished run.
RUN=$(curl -sS --fail-with-body -X POST "$ACRUXCORE_BASE_URL/agents/Help%20desk/runs" \
-H "Authorization: Bearer $ACRUXCORE_API_KEY" -H 'Content-Type: application/json' \
-d '{"message": "I bought a Trail 2 tent three weeks ago and used it once. Can I still return it, and how much do I get back?", "newConversation": true}')
CONVERSATION_ID=$(jq -r .conversationId <<<"$RUN")
jq -r .output <<<"$RUN"
jq -n --arg c "$CONVERSATION_ID" '{message: "Where is my order 20401?", conversationId: $c}' |
curl -sS --fail-with-body -X POST "$ACRUXCORE_BASE_URL/agents/Help%20desk/runs" \
-H "Authorization: Bearer $ACRUXCORE_API_KEY" -H 'Content-Type: application/json' -d @- |
jq -r .output
agents.stream yields each step while the agent works, then the finished run. QUESTIONS
is the list of the three questions in the Dashboard tab.
conversation_id = None
for question in QUESTIONS:
# Without new_conversation the run keeps no history and its conversation_id is None.
turn = {"conversation_id": conversation_id} if conversation_id else {"new_conversation": True}
async for event in hub.agents.stream("Help desk", message=question, **turn):
if event.type == "step.llm":
for call in event.data.get("toolCalls") or []:
print(f" model calls {call['name']}({call.get('arguments')})")
elif event.type == "run.failed" and event.run is None:
# A run that fails before it is recorded carries only the error.
raise SystemExit(f"The run failed: {event.data['error']['message']}")
elif event.run is not None:
conversation_id = event.run.conversation_id
print(f"A: {event.run.output}")
agents.stream yields each step while the agent works, then the finished run. QUESTIONS
is the list of the three questions in the Dashboard tab.
let conversationId;
for (const question of QUESTIONS) {
// Without newConversation the run keeps no history and its conversationId is null.
const turn = conversationId ? { conversationId } : { newConversation: true };
for await (const event of hub.agents.stream('Help desk', { message: question, ...turn })) {
if (event.type === 'step.llm') {
for (const call of event.toolCalls) console.log(` model calls ${call.name}(${call.arguments})`);
} else if (event.type === 'run.failed' && !event.run) {
// A run that fails before it is recorded carries only the error.
throw new Error(`The run failed: ${event.error.message}`);
} else if (event.type === 'run.completed' || event.type === 'run.failed') {
conversationId = event.run.conversationId;
console.log(`A: ${event.run.output}`);
}
}
}
The answers match the data. A used tent can be returned within 30 days for 80% of the price.
Order 20401 was delivered on November 25, 2026. cooking has the most returns, 4, and 7
orders are still processing.
7. Read the trace
Click View trace under the third answer. The trace has one row per step. Each LLM row is one model call, and the numbered rows under it are the tool calls that model call asked for.

In this run, the first model call asked for two queries at once, and the second one failed. Click that row to see why: the model added stray characters after the SQL, and DuckDB refused it with a parser error. The model got the error message back as the tool's result, wrote that query again in the next step, and answered from its result.

The model writes its SQL again on every run, so your run may have no failed call. When a call
does fail, the trace shows the failed call and the retry. The trace's status says Error as
soon as any one of its steps failed, even when the run recovered and answered. The run's
own status, succeeded, says whether the agent answered.
Run it
The scripts run steps 1 to 6 for you. Run the setup once, then ask as often as you like:
- curl
- Python
- Node
cd scripts/tutorials/build-a-help-desk-agent
bash bash/setup_help_desk.sh
bash bash/ask_help_desk.sh
cd scripts/tutorials/build-a-help-desk-agent
python python/setup_help_desk.py
python python/ask_help_desk.py
cd scripts/tutorials/build-a-help-desk-agent
node typescript/setup_help_desk.mjs
node typescript/ask_help_desk.mjs
Agent Help desk (a67dc20d-df5d-4aa9-b6bb-6fd38446f117)
search_help_desk_policies
query_help_desk_orders
Q: I bought a Trail 2 tent three weeks ago and used it once. Can I still return it, and how much do I get back?
model calls search_help_desk_policies({"query":"returns"})
A: You can return your Trail 2 tent since you are within the 30-day return window. Since the tent was used, you'll get back 80% of the price. Please ensure it's clean, dry, and undamaged for the return. If you need assistance with the return process, just let me know!
status=succeeded cost=$0.000232 trace=b20eab4c-47ee-4ef7-a359-8bcac1cdff9a
Q: Where is my order 20401?
model calls query_help_desk_orders({"sql":"SELECT * FROM orders WHERE order_id = 20401"})
A: Your order #20401 for the Ridge 45 backpack has been delivered on November 25, 2026. If you have any further questions, feel free to ask!
status=succeeded cost=$0.000312 trace=b3daf96b-0732-4898-94e6-1a93d0826998
Q: Which product category was returned most often, and how many orders are still waiting to ship?
model calls query_help_desk_orders({"sql": "SELECT category, COUNT(*) as count FROM orders WHERE status = 'returned' GROUP BY category ORDER BY count DESC LIMIT 1;"})
model calls query_help_desk_orders({"sql": "SELECT COUNT(*) as count FROM orders WHERE status = 'processing';"})
A: The product category that was returned most often is "cooking," with 4 returns. Additionally, there are currently 7 orders still waiting to ship. If you need more information, just let me know!
status=succeeded cost=$0.000273 trace=b5dca4df-9753-4c77-aa3e-11d0b3778f9e
The setup reads the model names from CHAT_MODEL and EMBED_MODEL, which default to
gpt-4o-mini and text-embedding-3-small. Set RERANK_MODEL and DECISION_MODEL to the
names of a rerank model and a decision model to rerank and filter the policy search as well.
To start again, run the teardown script, which deletes the agent, the prompt and both bases.
What's next
- Embed an agent on your website puts the Help desk on the shop's site as a chat button, with a per-visitor limit and a daily spend cap.
- Rerank and filter an agent's search results adds a reranker and a decision model to the policy search, and shows each stage in the trace.
- Let an agent count and filter a spreadsheet covers tables bases in more detail: Excel sheets, editing rows and the limits on a query.
- Run an agent with a knowledge base and a tool adds an HTTP tool from the catalog next to the knowledge bases.