Objective
A real support agent needs five things at once: it must remember the customer's past tickets, answer from your help docs (RAG), route the request to the right queue, score urgency, and understand how the customer relates to accounts and products. Teams usually stitch a vector store + a cache + a graph DB + a model server + glue to get there. Here you'll build the whole agent on one database, composing the building-block recipes from this cluster into a working support brain. The same brain drives any framework or a voice agent — see Use it from your agent at the end.
Step 1: Create the support knowledge base (for RAG)
Help-doc chunks the agent answers from, embedded for retrieval.
CREATE TABLE IF NOT EXISTS recipe_support_kb (
chunk_id INTEGER PRIMARY KEY,
source TEXT,
content TEXT,
embedding VECTOR(384)
);
INSERT INTO recipe_support_kb (chunk_id, source, content) VALUES
(1,'refunds.md','Refunds are available within 30 days of purchase to the original payment method.'),
(2,'login.md','If you are locked out, use Forgot Password on the sign-in page to reset via email.'),
(3,'billing.md','To update your card, go to Settings > Billing and edit the payment method.'),
(4,'outage.md','Service status and incident history are posted at status.example.com.'),
(5,'data.md','Export your data anytime from Settings > Privacy as a JSON download.');
UPDATE recipe_support_kb SET embedding = EMBED(content);
Step 2: Create the intent router (labeled examples)
A few examples per support intent so the agent can route by meaning.
CREATE TABLE IF NOT EXISTS recipe_support_intents (
example_id INTEGER PRIMARY KEY,
intent TEXT,
utterance TEXT,
embedding VECTOR(384)
);
INSERT INTO recipe_support_intents (example_id, intent, utterance) VALUES
(1,'billing','I was charged twice and need a refund.'),
(2,'billing','How do I update my credit card?'),
(3,'access','I can''t log in, I''m locked out.'),
(4,'access','Reset my password please.'),
(5,'outage','Is the service down right now?'),
(6,'outage','Everything is timing out for my whole team.');
UPDATE recipe_support_intents SET embedding = EMBED(utterance);
Step 3: Create the customer memory (past tickets)
Per-customer ticket history, embedded so the agent recalls relevant prior issues.
CREATE TABLE IF NOT EXISTS recipe_support_memory (
ticket_id INTEGER PRIMARY KEY,
customer_id TEXT,
summary TEXT,
embedding VECTOR(384)
);
INSERT INTO recipe_support_memory (ticket_id, customer_id, summary) VALUES
(1,'cust-7','Reported slow report exports; resolved by enabling pagination.'),
(2,'cust-7','Asked about upgrading to the Pro plan for more projects.'),
(3,'cust-7','Had trouble logging in after changing email; resolved via password reset.');
UPDATE recipe_support_memory SET embedding = EMBED(summary);
Step 4: Train a priority-scoring model (AutoML)
Learn which ticket features predict an urgent (P1) ticket from past resolutions.
CREATE TABLE IF NOT EXISTS recipe_support_history (
hist_id INTEGER PRIMARY KEY,
affects_team INTEGER, -- 1 if multiple users impacted
is_paying INTEGER, -- 1 if on a paid plan
mins_blocked INTEGER, -- minutes the user has been blocked
prior_tickets INTEGER, -- how many tickets this customer filed before
urgent INTEGER -- label: 1 = P1
);
INSERT INTO recipe_support_history
(hist_id, affects_team, is_paying, mins_blocked, prior_tickets, urgent) VALUES
(1,1,1,120,3,1),(2,0,0,5,0,0),(3,1,1,200,5,1),(4,0,1,15,1,0),
(5,1,1,90,2,1),(6,0,0,3,0,0),(7,1,1,150,4,1),(8,0,1,10,1,0),
(9,1,1,75,2,1),(10,0,0,8,0,0),(11,1,1,180,6,1),(12,0,1,20,1,0),
(13,1,1,110,3,1),(14,0,0,4,0,0),(15,1,1,140,5,1),(16,0,1,12,1,0),
(17,1,1,95,2,1),(18,0,0,6,0,0),(19,1,1,160,4,1),(20,0,1,18,1,0);
CREATE EXPERIMENT support_priority_exp AS
SELECT affects_team, is_paying, mins_blocked, prior_tickets, urgent AS target
FROM recipe_support_history
WITH (
task_type = 'binary_classification',
target_column = 'target',
optimization_metric = 'auc',
algorithms = ['logistic_regression', 'random_forest', 'gradient_boosting'],
validation_strategy = 'stratified_kfold',
n_folds = 3,
max_trials = 15
);
DEPLOY MODEL support_priority FROM EXPERIMENT support_priority_exp;
Step 5: Build the customer graph (relationships)
Who the customer is, the account they belong to, and the product they use — for relationship-aware handling.
MERGE (c:Customer {id: 'cust-7', name: 'Dana'})
MERGE (a:Account {id: 'acct-9', tier: 'Pro'})
MERGE (p:Product {name: 'Analytics'})
MERGE (c)-[:MEMBER_OF]->(a)
MERGE (a)-[:USES]->(p)
MERGE (c)-[:OPENED]->(t:Ticket {id: 'T-100', topic: 'login'});
Step 6: A ticket arrives — route it by intent
Classify the incoming message so it lands in the right queue.
SELECT intent, AVG(similarity) AS confidence
FROM (
SELECT intent,
COSINE_SIMILARITY(embedding, EMBED('my whole team is getting timeouts, nothing loads')) AS similarity
FROM recipe_support_intents
ORDER BY similarity DESC
LIMIT 4
)
GROUP BY intent
ORDER BY confidence DESC
LIMIT 1;