AI Support Team
Build an intelligent customer support team that routes inquiries to specialized agents for documentation search, issue escalation, and feedback collection. This example demonstrates advanced routing with knowledge bases and external integrations.
What You'll Learn
By building this team, you'll understand:
- How to create a routing system that classifies and directs customer inquiries
- How to integrate knowledge bases with vector search for documentation assistance
- How to connect external tools like Slack for escalation and feedback workflows
- How to combine multiple specialized agents with distinct responsibilities
Use Cases
Build customer support platforms, help desk systems, technical documentation assistants, or automated ticketing systems.
How It Works
The team uses intelligent routing to direct inquiries to specialized agents:
- Classify: Team leader analyzes the inquiry type (question, bug, feedback)
- Route: Directs to appropriate agent based on classification
- Process: Specialized agent handles the inquiry with their tools
- Integrate: Connects with external systems (Slack, knowledge base)
- Respond: Provides professional response back to the user
Each agent has specific tools and instructions for their domain of responsibility.
Code
1from kern.agent import Agent2from kern.knowledge.knowledge import Knowledge3from kern.knowledge.reader.website_reader import WebsiteReader4from kern.models.openai import OpenAIResponses5from kern.team import Team6from kern.tools.duckduckgo import DuckDuckGoTools7from kern.tools.exa import ExaTools8from kern.tools.slack import SlackTools9from kern.vectordb.pgvector import PgVector1011knowledge = Knowledge(12 vector_db=PgVector(13 table_name="website_documents",14 db_url="postgresql+psycopg://ai:ai@localhost:5532/ai",15 ),16)1718knowledge.insert(19 url="https://kern.ndx.rocks/introduction",20 reader=WebsiteReader(21 # Number of links to follow from the seed URLs22 max_links=10,23 ),24)25support_channel = "testing"26feedback_channel = "testing"2728doc_researcher_agent = Agent(29 name="Doc researcher Agent",30 role="Search the knowledge base for information",31 model=OpenAIResponses(id="gpt-5.2"),32 tools=[DuckDuckGoTools(), ExaTools()],33 knowledge=knowledge,34 search_knowledge=True,35 instructions=[36 "You are a documentation expert for given product. Search the knowledge base thoroughly to answer user questions.",37 "Always provide accurate information based on the documentation.",38 "If the question matches an FAQ, provide the specific FAQ answer from the documentation.",39 "When relevant, include direct links to specific documentation pages that address the user's question.",40 "If you're unsure about an answer, acknowledge it and suggest where the user might find more information.",41 "Format your responses clearly with headings, bullet points, and code examples when appropriate.",42 "Always verify that your answer directly addresses the user's specific question.",43 "If you cannot find the answer in the documentation knowledge base, use the DuckDuckGoTools or ExaTools to search the web for relevant information to answer the user's question.",44 ],45)464748escalation_manager_agent = Agent(49 name="Escalation Manager Agent",50 role="Escalate the issue to the slack channel",51 model=OpenAIResponses(id="gpt-5.2"),52 tools=[SlackTools()],53 instructions=[54 "You are an escalation manager responsible for routing critical issues to the support team.",55 f"When a user reports an issue, always send it to the #{support_channel} Slack channel with all relevant details using the send_message toolkit function.",56 "Include the user's name, contact information (if available), and a clear description of the issue.",57 "After escalating the issue, respond to the user confirming that their issue has been escalated.",58 "Your response should be professional and reassuring, letting them know the support team will address it soon.",59 "Always include a ticket or reference number if available to help the user track their issue.",60 "Never attempt to solve technical problems yourself - your role is strictly to escalate and communicate.",61 ],62)6364feedback_collector_agent = Agent(65 name="Feedback Collector Agent",66 role="Collect feedback from the user",67 model=OpenAIResponses(id="gpt-5.2"),68 tools=[SlackTools()],69 description="You are an AI agent that can collect feedback from the user.",70 instructions=[71 "You are responsible for collecting user feedback about the product or feature requests.",72 f"When a user provides feedback or suggests a feature, use the Slack tool to send it to the #{feedback_channel} channel using the send_message toolkit function.",73 "Include all relevant details from the user's feedback in your Slack message.",74 "After sending the feedback to Slack, respond to the user professionally, thanking them for their input.",75 "Your response should acknowledge their feedback and assure them that it will be taken into consideration.",76 "Be warm and appreciative in your tone, as user feedback is valuable for improving our product.",77 "Do not promise specific timelines or guarantee that their suggestions will be implemented.",78 ],79)808182customer_support_team = Team(83 name="Customer Support Team",84 model=OpenAIResponses(id="gpt-5.2"),85 members=[doc_researcher_agent, escalation_manager_agent, feedback_collector_agent],86 markdown=True,87 debug_mode=True,88 show_members_responses=True,89 determine_input_for_members=False,90 respond_directly=True,91 instructions=[92 "You are the lead customer support agent responsible for classifying and routing customer inquiries.",93 "Carefully analyze each user message and determine if it is: a question that needs documentation research, a bug report that requires escalation, or product feedback.",94 "For general questions about the product, route to the doc_researcher_agent who will search documentation for answers.",95 "If the doc_researcher_agent cannot find an answer to a question, escalate it to the escalation_manager_agent.",96 "For bug reports or technical issues, immediately route to the escalation_manager_agent.",97 "For feature requests or product feedback, route to the feedback_collector_agent.",98 "Always provide a clear explanation of why you're routing the inquiry to a specific agent.",99 "After receiving a response from the appropriate agent, relay that information back to the user in a professional and helpful manner.",100 "Ensure a seamless experience for the user by maintaining context throughout the conversation.",101 ],102)103104# Add in the query and the agent redirects it to the appropriate agent105customer_support_team.print_response(106 "Hi Team, I want to build an educational platform where the models are have access to tons of study materials, How can Kern platform help me build this?",107 stream=True,108)109# customer_support_team.print_response(110# "[Feature Request] Support json schemas in Gemini client in addition to pydantic base model",111# stream=True,112# )113# customer_support_team.print_response(114# "[Feature Request] Can you please update me on the above feature",115# stream=True,116# )117# customer_support_team.print_response(118# "[Bug] Async tools in team of agents not awaited properly, causing runtime errors ",119# stream=True,120# )What to Expect
The team will analyze your inquiry and route it to the most appropriate agent. Documentation questions get answered by searching the knowledge base, bugs get escalated to Slack, and feedback gets collected and logged.
You'll see the team's classification decision and responses from the specific agents handling your request. The knowledge base integration enables accurate answers grounded in actual documentation, while Slack integration provides seamless escalation workflows.
Usage
Set up your virtual environment
1uv venv --python 3.122source .venv/bin/activate1uv venv --python 3.122.venv\Scripts\activateSet your API keys
1export OPENAI_API_KEY=xxx2export SLACK_TOKEN=xxx3export EXA_API_KEY=xxxStart PostgreSQL database
1docker run -d --name pgvector-db -e POSTGRES_USER=ai -e POSTGRES_PASSWORD=ai -e POSTGRES_DB=ai -p 5532:5432 pgvector/pgvector:pg16Install dependencies
1uv pip install -U kern-ai openai ddgs slack-sdk exa-py pgvector psycopgRun Team
1python ai_support_team.py1python ai_support_team.pyNext Steps
- Modify the documentation URL in
knowledge.insert()to index your own docs - Adjust Slack channel names in
support_channelandfeedback_channelvariables - Add more specialized agents for different inquiry types
- Explore Knowledge Bases for advanced configurations