Learn to build an intelligent customer support system that can classify, research, and respond to inquiries automatically.
This tutorial will guide you through creating a complete customer support automation system using all of Motte's tools. The system will be able to classify incoming tickets, search for relevant information, generate responses, and learn from feedback.
Customer Inquiry ↓ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │ Classifier │───▶│ Knowledge │───▶│ Response │───▶│ Quality │ │ Agent │ │ Retrieval │ │ Generator │ │ Review │ └─────────────┘ └─────────────┘ └─────────────┘ └─────────────┘ │ │ │ │ ▼ ▼ ▼ ▼ Category Relevant Info Draft Response Final Response
First, we'll create a knowledge base with common support information.
"You are a customer support classifier. Categorize each inquiry into one of these categories: BILLING, TECHNICAL, SHIPPING, ACCOUNT, REFUND, OTHER. Respond with only the category name and a brief reason."
"You are a knowledge retrieval agent. Based on the customer inquiry and category, search the knowledge base for relevant information. Return the most relevant policies, procedures, or answers that address the customer's question."
"You are a customer support response writer. Create a helpful, professional, and empathetic response to the customer inquiry using the provided knowledge base information. Be specific, actionable, and maintain a friendly tone."
"You are a quality assurance agent. Review the customer support response for accuracy, completeness, tone, and helpfulness. Suggest improvements or approve the response. Ensure it fully addresses the customer's concern."
Connect external tools to enhance the support system's capabilities.
Purpose: Fetch customer history and account details
Endpoint: https://api.crm.com/v1/customers
Authentication: API Key
Purpose: Create and update support tickets
Endpoint: https://api.helpdesk.com/v2/tickets
Authentication: OAuth 2.0
Improve the system's performance using reinforcement learning with customer feedback.
{"prompt": "Customer says: I want to return my order", "expected_result": "Refund policy explanation with steps", "category": "REFUND"} {"prompt": "Customer says: I can't log into my account", "expected_result": "Password reset instructions", "category": "ACCOUNT"} {"prompt": "Customer says: Where is my package?", "expected_result": "Shipping status and tracking info", "category": "SHIPPING"}
def reward_fn(completion, **kwargs): response = completion[0].get('content', '') expected = kwargs.get('expected_result', '') category = kwargs.get('category', '') # Check if response addresses the category category_keywords = { 'REFUND': ['refund', 'return', 'money back'], 'ACCOUNT': ['password', 'login', 'account'], 'SHIPPING': ['shipping', 'delivery', 'tracking'] } keywords = category_keywords.get(category, []) keyword_score = sum(1 for kw in keywords if kw in response.lower()) / len(keywords) # Check if response is helpful and complete helpful_words = ['please', 'help', 'steps', 'instructions', 'contact'] helpful_score = min(1.0, sum(1 for hw in helpful_words if hw in response.lower()) / 3) # Combine scores return (keyword_score * 0.6) + (helpful_score * 0.4)
Set up monitoring to track system performance and identify areas for improvement.