关于 conversational-ai-flow
用于设计和实现对话式 AI 流程的技能,面向构建聊天机器人的从业者。内容涵盖状态管理、意图路由、槽位填充、错误恢复、回复生成及流程指标。
主要功能
- 01对话状态与流程位置管理
- 02基于意图的流程路由
- 03槽位填充与验证
- 04误解后的恢复策略
- 05上下文与多模态回复
- 06完成率与回退指标
适用场景
- 01设计预约对话流程
- 02处理对话中的信息缺失
- 03应对多次误解后的恢复
- 04监控完成率与中途退出
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ dengineproblem/ agents-monorepo --skill conversational-ai-flow安装后在 Claude Code 中输入/conversational-ai-flow确认已加载。
详细介绍
对话式 AI 工作流专家
专注于对话式 AI 工作流的设计与实现。
核心设计原则
状态管理
class ConversationState:
def __init__(self):
self.current_intent = None
self.entities = {}
self.conversation_history = []
self.flow_position = "start"
self.confidence_threshold = 0.7
def update_context(self, user_input, intent, entities):
self.conversation_history.append({
"user_input": user_input,
"intent": intent,
"entities": entities
})
self.entities.update(entities)
self.current_intent = intent
工作流架构模式
基于意图的路由
flows:
booking_flow:
entry_conditions:
- intent: "book_appointment"
steps:
- name: "collect_datetime"
prompt: "When would you like to schedule?"
validation: "datetime_validator"
- name: "confirm_booking"
prompt: "Confirm booking on {datetime}?"
actions: ["create_booking", "send_confirmation"]
fallback_flow:
triggers: ["low_confidence", "unknown_intent"]
strategy: "clarification_questions"
槽位填充模式
def slot_filling_handler(state, required_slots):
missing_slots = [s for s in required_slots if s not in state.entities]
if missing_slots:
return generate_slot_prompt(missing_slots[0], state)
return proceed_to_next_step(state)
错误处理与恢复
渐进式展开
class ErrorRecovery:
def handle_misunderstanding(self, state, attempt_count):
strategies = {
1: "I didn't quite catch that. Could you rephrase?",
2: "Let me try differently. Are you looking to: [options]?",
3: "Let me connect you with a human agent."
}
return strategies.get(attempt_count, strategies[3])
响应生成
情境化模板
class ResponseGenerator:
templates = {
"confirmation": [
"Got it! {summary}. Is that correct?",
"Let me confirm: {summary}. Does this look right?"
],
"progress": [
"Great! We've got {completed}. Next, {next_step}.",
"Perfect! Just need {remaining} and we're done."
]
}
多模态响应
{
"response_type": "rich",
"text": "Here are your options:",
"components": [
{
"type": "quick_replies",
"options": [
{"title": "Schedule Appointment", "payload": "intent:book"},
{"title": "Check Status", "payload": "intent:status"}
]
}
]
}
分析与优化
def track_flow_metrics(conversation_id, metrics):
return {
"completion_rate": metrics.completed / metrics.started,
"average_turns": metrics.total_turns / metrics.conversations,
"fallback_rate": metrics.fallbacks / metrics.total_turns,
"abandonment_points": identify_drop_off_points(conversation_id)
}
最佳实践
- 明确机器人的个性和语气
- 预判用户需求
- 为较长的对话使用摘要
- 测试所有路径和边界情况
- 监控真实对话,以便改进
评论
支持 Markdown