mirror of
https://github.com/aljazceru/enclava.git
synced 2025-12-17 07:24:34 +01:00
182 lines
6.9 KiB
JSON
182 lines
6.9 KiB
JSON
{
|
|
"name": "Customer Support Workflow",
|
|
"description": "Intelligent customer support workflow with intent classification, knowledge base search, and chatbot response generation",
|
|
"version": "1.0",
|
|
"variables": {
|
|
"support_chatbot_id": "cs-bot-001",
|
|
"escalation_threshold": 0.3,
|
|
"max_attempts": 3
|
|
},
|
|
"steps": [
|
|
{
|
|
"id": "classify_intent",
|
|
"name": "Classify Customer Intent",
|
|
"type": "llm_call",
|
|
"model": "gpt-3.5-turbo",
|
|
"messages": [
|
|
{
|
|
"role": "system",
|
|
"content": "You are an intent classifier for customer support. Classify the customer message into one of these categories: technical_issue, billing_question, feature_request, complaint, general_inquiry. Also provide a confidence score between 0 and 1. Respond with JSON: {\"intent\": \"category\", \"confidence\": 0.95, \"reasoning\": \"explanation\"}"
|
|
},
|
|
{
|
|
"role": "user",
|
|
"content": "{{ inputs.customer_message }}"
|
|
}
|
|
],
|
|
"output_variable": "intent_classification"
|
|
},
|
|
|
|
{
|
|
"id": "search_knowledge_base",
|
|
"name": "Search Knowledge Base",
|
|
"type": "workflow_step",
|
|
"module": "rag",
|
|
"action": "search",
|
|
"config": {
|
|
"query": "{{ inputs.customer_message }}",
|
|
"collection": "support_documentation",
|
|
"top_k": 5,
|
|
"include_metadata": true
|
|
},
|
|
"output_variable": "knowledge_results"
|
|
},
|
|
|
|
{
|
|
"id": "check_confidence",
|
|
"name": "Check Intent Confidence",
|
|
"type": "condition",
|
|
"condition": "JSON.parse(steps.classify_intent.result).confidence > variables.escalation_threshold",
|
|
"true_steps": [
|
|
{
|
|
"id": "generate_chatbot_response",
|
|
"name": "Generate Chatbot Response",
|
|
"type": "workflow_step",
|
|
"module": "chatbot",
|
|
"action": "workflow_chat_step",
|
|
"config": {
|
|
"message": "{{ inputs.customer_message }}",
|
|
"chatbot_id": "{{ variables.support_chatbot_id }}",
|
|
"use_rag": true,
|
|
"context": {
|
|
"intent": "{{ steps.classify_intent.result }}",
|
|
"knowledge_base_results": "{{ steps.search_knowledge_base.result }}",
|
|
"customer_history": "{{ inputs.customer_history }}",
|
|
"additional_instructions": "Be empathetic and professional. If you cannot fully resolve the issue, offer to escalate to a human agent."
|
|
}
|
|
},
|
|
"output_variable": "chatbot_response"
|
|
},
|
|
|
|
{
|
|
"id": "analyze_response_quality",
|
|
"name": "Analyze Response Quality",
|
|
"type": "llm_call",
|
|
"model": "gpt-3.5-turbo",
|
|
"messages": [
|
|
{
|
|
"role": "system",
|
|
"content": "Analyze if this customer support response adequately addresses the customer's question. Consider completeness, accuracy, and helpfulness. Respond with JSON: {\"quality_score\": 0.85, \"is_adequate\": true, \"requires_escalation\": false, \"reasoning\": \"explanation\"}"
|
|
},
|
|
{
|
|
"role": "user",
|
|
"content": "Customer Question: {{ inputs.customer_message }}\\n\\nChatbot Response: {{ steps.generate_chatbot_response.result.response }}\\n\\nKnowledge Base Context: {{ steps.search_knowledge_base.result }}"
|
|
}
|
|
],
|
|
"output_variable": "response_quality"
|
|
},
|
|
|
|
{
|
|
"id": "final_response_decision",
|
|
"name": "Final Response Decision",
|
|
"type": "condition",
|
|
"condition": "JSON.parse(steps.analyze_response_quality.result).is_adequate === true",
|
|
"true_steps": [
|
|
{
|
|
"id": "send_chatbot_response",
|
|
"name": "Send Chatbot Response",
|
|
"type": "output",
|
|
"config": {
|
|
"response_type": "chatbot_response",
|
|
"message": "{{ steps.generate_chatbot_response.result.response }}",
|
|
"sources": "{{ steps.generate_chatbot_response.result.sources }}",
|
|
"confidence": "{{ JSON.parse(steps.classify_intent.result).confidence }}",
|
|
"quality_score": "{{ JSON.parse(steps.analyze_response_quality.result).quality_score }}"
|
|
}
|
|
}
|
|
],
|
|
"false_steps": [
|
|
{
|
|
"id": "escalate_to_human",
|
|
"name": "Escalate to Human Agent",
|
|
"type": "output",
|
|
"config": {
|
|
"response_type": "human_escalation",
|
|
"message": "I'd like to connect you with one of our human support agents who can better assist with your specific situation. Please hold on while I transfer you.",
|
|
"escalation_reason": "Response quality below threshold",
|
|
"intent": "{{ steps.classify_intent.result }}",
|
|
"attempted_response": "{{ steps.generate_chatbot_response.result.response }}",
|
|
"priority": "normal"
|
|
}
|
|
}
|
|
]
|
|
}
|
|
],
|
|
"false_steps": [
|
|
{
|
|
"id": "low_confidence_escalation",
|
|
"name": "Low Confidence Escalation",
|
|
"type": "output",
|
|
"config": {
|
|
"response_type": "human_escalation",
|
|
"message": "I want to make sure you get the best possible help. Let me connect you with one of our human support agents.",
|
|
"escalation_reason": "Low intent classification confidence",
|
|
"intent": "{{ steps.classify_intent.result }}",
|
|
"priority": "high"
|
|
}
|
|
}
|
|
]
|
|
},
|
|
|
|
{
|
|
"id": "log_interaction",
|
|
"name": "Log Customer Interaction",
|
|
"type": "workflow_step",
|
|
"module": "analytics",
|
|
"action": "log_event",
|
|
"config": {
|
|
"event_type": "customer_support_interaction",
|
|
"data": {
|
|
"customer_message": "{{ inputs.customer_message }}",
|
|
"intent_classification": "{{ steps.classify_intent.result }}",
|
|
"response_generated": "{{ steps.generate_chatbot_response.result.response }}",
|
|
"knowledge_base_used": "{{ steps.search_knowledge_base.result }}",
|
|
"escalated": "{{ outputs.response_type === 'human_escalation' }}",
|
|
"workflow_execution_time": "{{ execution_time }}",
|
|
"timestamp": "{{ current_timestamp }}"
|
|
}
|
|
}
|
|
}
|
|
],
|
|
|
|
"outputs": {
|
|
"response_type": "string",
|
|
"message": "string",
|
|
"sources": "array",
|
|
"escalation_reason": "string",
|
|
"confidence": "number",
|
|
"quality_score": "number"
|
|
},
|
|
|
|
"error_handling": {
|
|
"retry_failed_steps": true,
|
|
"max_retries": 2,
|
|
"fallback_response": "I apologize, but I'm experiencing technical difficulties. Please contact our support team directly for assistance."
|
|
},
|
|
|
|
"metadata": {
|
|
"created_by": "support_team",
|
|
"use_case": "customer_support_automation",
|
|
"tags": ["customer_support", "chatbot", "rag", "escalation"],
|
|
"estimated_execution_time": "5-15 seconds"
|
|
}
|
|
} |