客服对话中的角色设置
BrightCart 自从上线新界面后,在线聊天量翻了一倍。您正在训练一个支持机器人,能即时处理简单常见问题,但凡涉及账号访问或深入技术修复的,都需要升级转人工。 例如,机器人可以处理重置密码和物流到达时间等问题;但账单错误或应用崩溃必须转交给人工客服。
请为 Claude 提供几个示例对话轮次,固定这种处理方式,确保客户要么能从机器人获得快速帮助,要么能顺畅转接到专业人员。
anthropic 库、client 以及 customer_question 变量已预加载。
本练习是课程的一部分
Claude 模型入门
练习说明
- 为关于密码问题的有用回复设置助手角色。
- 编写一个升级处理的回复,将账单相关问题引导至人工支持。
- 使用用户角色添加客户提问。
交互式实操练习
通过完成这段示例代码来试试这个练习。
messages = [
{"role": "user", "content": "How do I reset my password?"},
# Show how the bot handles simple questions
{"role": ____, "content": "Click 'Forgot Password' on the login page, enter your email, and check for our reset link."},
{"role": "user", "content": "Why is my account being charged twice?"},
# Demonstrate escalation for billing issues
{"role": "assistant", "content": ____},
# Add the new customer question for the bot to handle
{"role": ____, "content": customer_question}]
response = client.messages.create(
model="claude-sonnet-4-6", max_tokens=75,
messages=messages)
print(response.content[0].text)