Use case
Customer Support Bot
Deploy conversational AI with streaming responses, human-in-the-loop escalation, guardrails, and tool transparency.
- Stack Agent SDK + Agent Server + Chat UI + Console
- Pattern Chat · Support
- Read ~8 min
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 use case
If your team needs the capabilities described above and you would rather build on proven primitives than wire one from scratch — this is the shape to start from.
Run the example
Runnable code for this pattern is public on GitHub:
- console-examples /
06-approvals-and-webhooks: A webhook receiver that verifies signatures and answers agent tool approvals through the client API. - agent-sdk /
examples/tool-approval: Flags a tool withneedsApproval, pauses the run, records a human decision and resumes: the refund escalation in step 2. - agent-sdk /
examples/guardrails: Request and response guardrails that block unsafe or off-topic messages. - agent-server /
examples/standalone: A complete agent server with tools that need approval, questions, files and cancel, plus Swagger UI and a browser UI. - chat-ui /
examples/nextjs-basic.tsx: TheChatcomponent in a Next.js page, the customer-facing surface in step 3.
Architecture
Console provides the AI control plane 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
Products used
This pattern combines 4 Cognipeer products.
Agent SDK
Deterministic TypeScript agent runtime — planning, tools, guardrails, sub-agents, and human-in-the-loop.
Agent Server
Serve agents as versioned REST APIs with streaming, auth, storage, and OpenAPI docs.
Chat UI
React components for a production chat surface — streaming, tool cards, uploads, and theming.
Console
Self-hosted AI control plane — routing, embeddings, vectors, files, guardrails, and tracing.
Related use cases
Agent Approvals Through Webhooks
Pause an agent before it runs a risky tool, get a signed webhook, and approve or deny from your own backend with the client API.
Embedded Portal With Page Tools
Embed a Console portal as a chat bubble in your product, sign visitors in with your own identity token, and let the agent act on the page.
Let Users Choose The Agent's Model
Offer a main model plus additional models on one agent and let the caller, or a chat UI model picker, choose which one answers.
Autonomous AI Agents
Build agents that plan, execute tools, and deliver structured outputs with full deterministic control and observability.
See every pattern on the use case index, or browse all Cognipeer libraries.

