Overview

A customer support bot needs to be reliable, safe, and transparent. Cognipeer provides guardrails to keep the agent on-topic, human-in-the-loop for sensitive decisions, and full tracing for quality assurance.

This guide builds a support bot that can look up orders, answer FAQs from a knowledge base, and escalate to humans when needed.

When to reach for this recipe

If your team needs the capabilities described above and you'd rather build on proven primitives than wire one from scratch — this is the shape to start from.

Architecture

Console provides the AI gateway with guardrails, tracing, and the RAG pipeline for knowledge base access.

Agent SDK powers the agent runtime with human-in-the-loop checkpoints and safety controls.

Agent Server serves the agent as a REST API with conversation persistence.

Chat UI provides the customer-facing interface with streaming, tool cards, and file attachments.

1. Create Support Tools

Define the tools the support agent can use: order lookup, FAQ search, and human escalation.

1import { createTool } from "@cognipeer/agent-sdk";
2import { z } from "zod";
3 
4const lookupOrder = createTool({
5 name: "lookup_order",
6 description: "Look up order status by order ID",
7 schema: z.object({
8 orderId: z.string().describe("Customer order ID"),
9 }),
10 func: async ({ orderId }) => {
11 const order = await db.orders.findById(orderId);
12 return {
13 status: order.status,
14 items: order.items,
15 estimatedDelivery: order.estimatedDelivery,
16 };
17 },
18});
19 
20const searchFAQ = createTool({
21 name: "search_faq",
22 description: "Search the FAQ knowledge base",
23 schema: z.object({
24 query: z.string().describe("Customer question"),
25 }),
26 func: async ({ query }) => {
27 // Uses Console SDK for RAG
28 const results = await consoleClient.vectors.query(
29 "support-provider", "faq-index",
30 { query: { text: query, topK: 3 } }
31 );
32 return { answers: results.matches.map(m => m.metadata?.text) };
33 },
34});
35 
36const escalateToHuman = createTool({
37 name: "escalate",
38 description: "Escalate to a human support agent",
39 schema: z.object({
40 reason: z.string().describe("Reason for escalation"),
41 priority: z.enum(["low", "medium", "high"]),
42 }),
43 func: async ({ reason, priority }) => {
44 await ticketSystem.create({ reason, priority });
45 return { message: "Escalated to human agent" };
46 },
47});

2. Build the Agent with Guardrails

Create the support agent with human-in-the-loop for refunds and guardrails to keep responses professional and on-topic.

1import { createSmartAgent, fromLangchainModel } from "@cognipeer/agent-sdk";
2 
3const supportAgent = createSmartAgent({
4 name: "SupportBot",
5 model,
6 tools: [lookupOrder, searchFAQ, escalateToHuman],
7 systemPrompt: `You are a helpful customer support agent.
8Rules:
9- Always be polite and professional
10- Look up orders before answering order questions
11- Search FAQ for common questions
12- Escalate to human for: refunds, complaints, account issues
13- Never discuss competitor products
14- Never share internal policies`,
15 guardrails: {
16 input: [
17 { type: "content_filter", config: { blocked_topics: ["competitors"] } },
18 ],
19 output: [
20 { type: "pii_filter", config: { mask: true } },
21 ],
22 },
23 humanInTheLoop: {
24 requireApproval: ["escalate"],
25 },
26 tracing: { enabled: true },
27});

3. Serve and Connect UI

Register with Agent Server and add the Chat UI for customer interaction.

1// Server setup
2server.registerSDKAgent("support-bot", supportAgent, {
3 description: "Customer support assistant",
4 version: "1.0.0",
5});
6 
7// Chat UI
8<Chat
9 baseUrl="https://your-api.example.com/api/agents"
10 agentId="support-bot"
11 theme="light"
12 enableFileUpload={true}
13 placeholder="How can we help you today?"
14 themeColors={{
15 accentPrimary: "#16b3ab",
16 }}
17/>

Result

You now have a production support bot that:

- Looks up order information in real time - Searches an FAQ knowledge base using RAG - Escalates to humans when needed with approval flows - Guards against off-topic and unsafe content - Traces every interaction for quality review - Streams responses with full tool transparency

All recipesSuggest a change