Customer Support Bot
Deploy conversational AI with streaming responses, human-in-the-loop escalation, guardrails, and tool transparency.
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.
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.
import { createTool } from "@cognipeer/agent-sdk";
import { z } from "zod";
const lookupOrder = createTool({
name: "lookup_order",
description: "Look up order status by order ID",
schema: z.object({
orderId: z.string().describe("Customer order ID"),
}),
func: async ({ orderId }) => {
const order = await db.orders.findById(orderId);
return {
status: order.status,
items: order.items,
estimatedDelivery: order.estimatedDelivery,
};
},
});
const searchFAQ = createTool({
name: "search_faq",
description: "Search the FAQ knowledge base",
schema: z.object({
query: z.string().describe("Customer question"),
}),
func: async ({ query }) => {
// Uses Console SDK for RAG
const results = await consoleClient.vectors.query(
"support-provider", "faq-index",
{ query: { text: query, topK: 3 } }
);
return { answers: results.matches.map(m => m.metadata?.text) };
},
});
const escalateToHuman = createTool({
name: "escalate",
description: "Escalate to a human support agent",
schema: z.object({
reason: z.string().describe("Reason for escalation"),
priority: z.enum(["low", "medium", "high"]),
}),
func: async ({ reason, priority }) => {
await ticketSystem.create({ reason, priority });
return { message: "Escalated to human agent" };
},
});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.
import { createSmartAgent, fromLangchainModel } from "@cognipeer/agent-sdk";
const supportAgent = createSmartAgent({
name: "SupportBot",
model,
tools: [lookupOrder, searchFAQ, escalateToHuman],
systemPrompt: `You are a helpful customer support agent.
Rules:
- Always be polite and professional
- Look up orders before answering order questions
- Search FAQ for common questions
- Escalate to human for: refunds, complaints, account issues
- Never discuss competitor products
- Never share internal policies`,
guardrails: {
input: [
{ type: "content_filter", config: { blocked_topics: ["competitors"] } },
],
output: [
{ type: "pii_filter", config: { mask: true } },
],
},
humanInTheLoop: {
requireApproval: ["escalate"],
},
tracing: { enabled: true },
});3. Serve and Connect UI
Register with Agent Server and add the Chat UI for customer interaction.
// Server setup
server.registerSDKAgent("support-bot", supportAgent, {
description: "Customer support assistant",
version: "1.0.0",
});
// Chat UI
<Chat
baseUrl="https://your-api.example.com/api/agents"
agentId="support-bot"
theme="light"
enableFileUpload={true}
placeholder="How can we help you today?"
themeColors={{
accentPrimary: "#16b3ab",
}}
/>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