By Sagar Shankaran, Founder of CallSphere
Learn how to architect a customer support AI agent with intent classification, knowledge base integration, conversation state management, and escalation paths that handle real-world support complexity.
Key takeaways
Customer support follows predictable patterns. Most inquiries fall into a small set of categories — order status, billing questions, technical troubleshooting, returns. Within each category, the resolution path is well-defined. This structure makes support an ideal domain for agentic AI, where an agent can classify intent, retrieve relevant information, execute actions, and escalate only when necessary.
A well-designed support agent reduces average handle time by 60-80% for routine queries while preserving human intervention for complex cases. The key is getting the architecture right from the start.
A production support agent has four layers: intent classification, knowledge retrieval, action execution, and escalation management. Each layer feeds into the next, and the agent orchestrates them within a conversation loop.
Hear it before you finish reading
Talk to a live CallSphere AI voice agent in your browser — 60 seconds, no signup.
flowchart LR
USER(["Customer"])
CHANNEL{"Channel"}
CHAT["Chat agent"]
VOICE["Voice agent"]
EMAIL["Email agent"]
TRIAGE["Triage and<br/>intent detection"]
KB[("Knowledge base<br/>RAG")]
CRM[("CRM context")]
AUTORES{"Auto resolvable?"}
RESOLVE(["Resolved with<br/>cited answer"])
HUMAN(["Tier 2 agent"])
USER --> CHANNEL --> CHAT --> TRIAGE
CHANNEL --> VOICE --> TRIAGE
CHANNEL --> EMAIL --> TRIAGE
TRIAGE --> KB
TRIAGE --> CRM
TRIAGE --> AUTORES
AUTORES -->|Yes| RESOLVE
AUTORES -->|No| HUMAN
style TRIAGE fill:#4f46e5,stroke:#4338ca,color:#fff
style AUTORES fill:#f59e0b,stroke:#d97706,color:#1f2937
style RESOLVE fill:#059669,stroke:#047857,color:#fff
style HUMAN fill:#0ea5e9,stroke:#0369a1,color:#fff
from dataclasses import dataclass, field
from enum import Enum
from typing import Optional
class Intent(Enum):
ORDER_STATUS = "order_status"
BILLING = "billing"
TECHNICAL = "technical"
RETURNS = "returns"
GENERAL_FAQ = "general_faq"
UNKNOWN = "unknown"
class Priority(Enum):
LOW = "low"
MEDIUM = "medium"
HIGH = "high"
URGENT = "urgent"
@dataclass
class ConversationState:
session_id: str
customer_id: Optional[str] = None
intent: Intent = Intent.UNKNOWN
priority: Priority = Priority.MEDIUM
turn_count: int = 0
resolved: bool = False
escalated: bool = False
context: dict = field(default_factory=dict)
history: list = field(default_factory=list)
def add_turn(self, role: str, content: str):
self.history.append({"role": role, "content": content})
if role == "user":
self.turn_count += 1
The first thing the agent does with every user message is classify intent. This determines which tools and knowledge bases to activate. A two-stage approach works well: a fast keyword matcher for obvious cases, and an LLM classifier for ambiguous inputs.
import re
from openai import AsyncOpenAI
KEYWORD_PATTERNS = {
Intent.ORDER_STATUS: r"(where is my order|track|shipping|delivery|package)",
Intent.BILLING: r"(charge|invoice|payment|refund amount|bill)",
Intent.RETURNS: r"(return|exchange|send back|refund|warranty)",
Intent.TECHNICAL: r"(not working|error|bug|crash|broken|help with)",
}
def classify_by_keywords(message: str) -> Optional[Intent]:
lower = message.lower()
for intent, pattern in KEYWORD_PATTERNS.items():
if re.search(pattern, lower):
return intent
return None
async def classify_by_llm(
client: AsyncOpenAI, message: str, history: list
) -> Intent:
response = await client.chat.completions.create(
model="gpt-4o-mini",
messages=[
{
"role": "system",
"content": (
"Classify the customer intent. "
"Return exactly one of: order_status, billing, "
"technical, returns, general_faq, unknown"
),
},
*history[-4:],
{"role": "user", "content": message},
],
max_tokens=20,
)
label = response.choices[0].message.content.strip().lower()
try:
return Intent(label)
except ValueError:
return Intent.UNKNOWN
async def classify_intent(
client: AsyncOpenAI, message: str, history: list
) -> Intent:
keyword_result = classify_by_keywords(message)
if keyword_result:
return keyword_result
return await classify_by_llm(client, message, history)
The main agent loop ties everything together. After classifying intent, the agent retrieves context, attempts resolution, and decides whether to escalate based on confidence, sentiment, and turn count.
ESCALATION_THRESHOLDS = {
"max_turns": 5,
"low_confidence": 0.4,
"negative_sentiment": -0.6,
}
async def should_escalate(state: ConversationState, confidence: float, sentiment: float) -> bool:
if state.priority == Priority.URGENT:
return True
if state.turn_count >= ESCALATION_THRESHOLDS["max_turns"]:
return True
if confidence < ESCALATION_THRESHOLDS["low_confidence"]:
return True
if sentiment < ESCALATION_THRESHOLDS["negative_sentiment"]:
return True
return False
async def run_support_agent(state: ConversationState, user_message: str):
state.add_turn("user", user_message)
intent = await classify_intent(client, user_message, state.history)
state.intent = intent
# Retrieve relevant knowledge and generate response
knowledge = await retrieve_knowledge(intent, user_message)
response, confidence = await generate_response(
state, knowledge, user_message
)
sentiment = await analyze_sentiment(user_message)
if await should_escalate(state, confidence, sentiment):
state.escalated = True
return await transfer_to_human(state)
state.add_turn("assistant", response)
return response
This architecture keeps each concern isolated. You can swap out the intent classifier, upgrade the knowledge base, or adjust escalation rules without rewriting the conversation loop.
Start with five to eight broad intents that cover 80% of your ticket volume. You can add sub-intents later as you analyze misclassifications. Trying to cover every edge case from the start leads to fragile classifiers and overlapping categories.
Still reading? Stop comparing — try CallSphere live.
CallSphere ships complete AI voice agents per industry — 14 tools for healthcare, 10 agents for real estate, 4 specialists for salons. See how it actually handles a call before you book a demo.
For most teams, prompt-based classification with a fast model like GPT-4o-mini is the right starting point. It requires no training data and can be updated instantly. Fine-tuning becomes worthwhile once you have 1,000+ labeled examples per intent and need sub-50ms classification latency.
Detect multi-intent messages by running classification twice — once on each clause after splitting on conjunctions. Process the most urgent intent first, then address the second. Store both intents in conversation state so the agent can circle back naturally.
#CustomerSupport #AIAgents #ConversationDesign #IntentClassification #Escalation #AgenticAI #LearnAI #AIEngineering

Written by
Sagar Shankaran· Founder, CallSphere
LinkedInSagar Shankaran is the founder of CallSphere, where he builds production AI voice and chat agents deployed across healthcare, hospitality, real estate, and home services. He writes about agentic AI, LLM engineering, and shipping voice agents that handle real calls in production.
See how AI voice agents work for your industry. Live demo available -- no signup required.
Ukrainian online stores use CallSphere AI voice and chat agents to answer order, delivery and returns questions 24/7 in Ukrainian and Russian, recover abandoned carts and scale support without hiring.
Orange Money and MTN MoMo agents in Liberia field endless customer questions and support calls. See how CallSphere AI voice and chat agents answer 24/7 in English, cut support pressure, and capture leads from about $50 a month.
A founder's guide to the personal AI assistant market: best AI assistant apps, business-grade options, and how CallSphere's voice agent fits in.
A founder's guide to free AI agents, low-code AI agent builders, and how to know when you should pay for a real platform like CallSphere.
Graphiti is the open-source temporal knowledge graph for AI agents in 2026. Learn how bi-temporal memory beats vector RAG for voice agents and long-running LLMs.
Chatbot app vs ChatGPT in 2026: a founder's clear take on the difference, when to use which, and how a real AI chatbot app development works.
© 2026 CallSphere Inc. All rights reserved.
Made within San Francisco