客服對話的角色設定
BrightCart 推出新介面後,即時聊天量增加了 2 倍。你正訓練一個支援機器人,能即時處理簡單常見問答(FAQ),但凡是需要存取帳戶或進階技術修復的問題,就要升級轉交。 例如,機器人可以處理重設密碼與運送到貨時間(ETA)這類問題;但帳單錯誤或 App 當機則必須交由真人客服接手。
請提供 Claude 幾輪示範對話,鎖定這種行為,確保顧客要嘛能立即從機器人獲得協助,要嘛順暢地轉交給專員。
anthropic 函式庫、client,以及 customer_question 變數都已預先載入。
本練習屬於課程
Claude 模型入門
練習說明
- 為助理針對密碼相關問題的有幫助回應設定角色。
- 撰寫一段升級處理的回應,將帳務問題導向真人支援。
- 以 user 角色加入客戶提問。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
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)