IBM Watson™ 提供了許多服務,例如:Speech To Text、Text To Speech、Conversation Service 等,並在透過這些雲端服務可進行語音轉換與聊天機器人等情境的運用,本文根據 Watson Conversation Service - Car Tutorial 撰寫相關中文教學。
結構概況
執行步驟
Intent 元素
Entity 元素
Dialog 流程
Dialog 結果
JSON 格式
前置準備作業
- 準備 IBM Bluemix 帳號。
建立 Watson Conversation 服務
1. 登入到 IBM Bluemix
2. 點選右上方型錄
3. 點選左邊 Watson
4. 點選中間的 Conversation 服務
5. 點擊右下角建立
6. 點擊 Launch tool
- 將畫面往下拉到 Conversation tooling。
7. 點擊 Create
8. 取 Workspace 名稱並點擊 Create
- 依據 IBM Conversation Service - Tutorial,將名稱取名為 Car tutorial。
9. 點擊 Get started
10. 點擊 Create
11. 建立 Intent - turn_on
Intent name | User example ( 建立 5 個 ) |
---|---|
turn_on | lights |
Listen to some music | |
Play some tunes | |
Air on please | |
Turn on the headlights |
12. 點擊右上角 Done
13. 建立 Intent - greeting
- 點擊左上角 Create。
Intent name | User example ( 建立 5 個 ) |
---|---|
greeting | Hello |
Hi | |
Good morning | |
Good afternoon | |
Good evening |
14. 點擊右上角 Done
15.建立 Entities
- 點擊上方 Entities。
16. 點擊 Create
17. 建立 Entity - appliance
Entity | Value | Synonyms |
---|---|---|
appliance | music | radio |
headlights | lights | |
air conditioning | air |
18. 點擊右上角 Done
19.建立 Entity - genre
- 點擊左上角 Create。
Entity | Value | Synonyms |
---|---|---|
genre | classical | symphonic |
rhythm and blues | r&b | |
rock | pop |
20. 點擊右上角 Done
21. 建立 Dialog
- 點擊上方 Dialog。
注意:同一層的節點順序是有差
22. 點擊 Create
23. 建立開始節點資訊
Enter a condition | Watson says | Anything else |
---|---|---|
❖ 輸入 conversation_start 後會出現一個選單,請選擇 conversation_start (create new condition)。 | ❖ 輸入 Welcome to the car demo! | ❖ Watson says 的欄位輸入 I'm sorry, I don't understand. Please try again. |
❖ 亦指 conversation 開始時會自動觸發此節點。 | ❖ 亦指特定條件為 true 時 Watson 會回覆此訊息 (目前條件為 conversation 開始時)。 | ❖ 亦指使用者輸入的資訊無法找到相匹配的節點時 Watson 會回覆此訊息。 |
24. 測試剛建立的 Conversation
- 點擊右上方的按鈕開啟對話視窗,對話視窗馬上出現 Welcome to the car demo! 的訊息。
- 因尚未建立其它的節點,故隨意輸入一字串,則對話視窗會出現 I'm sorry, I don't understand. Please try again. 的訊息。
25. 建立 greeting intent 的對話分支
- 點選 conversation_start 節點下方的 + 號 (Create alternative conversation),以建立一個與 root 同階層的節點。
Enter a condition | Watson says |
---|---|
❖ 輸入 #greeting 後會出現一個選單,請選擇 #greeting。 | ❖ 輸入 Hi! What can I do for you? |
❖ 亦指輸入任何與 #greeting intent 相匹配的資訊,則此節點將會被觸發。 |
26. 測試剛建立的 Conversation
- 點擊右上方的按鈕開啟對話視窗。
- 輸入 Hello 並按下 Enter,因所輸入的文字能在
#greeting intent
中找到相匹配的資訊,故 Watson 會回覆 Hi! What can I do for you? 的訊息。
27.建立 turn_on intent 的對話分支
- 點選
#greeting
節點下方的 + 號 (Create alternative conversation),以建立一個與 root 同階層的節點。
Enter a condition | Watson says |
---|---|
❖ 輸入 #turn_on 後會出現一個選單,請選擇 #turn_on。 | ❖ 免輸入資訊。 |
❖ 當輸入任何與 #turn_on intent 相匹配的資訊時,則會觸發此節點。 | ❖ 對話需要有更多的資訊來讓 Watson 選擇一個適合的回應。 |
【 建立 #turn_on 的子節點 】點選 #turn_on
節點右邊 + 號 (Continue conversation),以建立子節點。
Enter a condition | Watson says |
---|---|
❖ 輸入 @appliance 後會出現一個選單,請選擇 @appliance。 | ❖ 免輸入資訊。 |
❖ 當使用者輸入任何與 @appliance entity 相匹配的資訊,則此節點將會被觸發。 | ❖ 對話需要有更多的資訊來讓 Watson 選擇一個適合的回應。 |
- 點擊
#turn_on
節點右上角的按鈕 ➙ Continue from ➙ 點擊@appliance
節點 ➙ Go to condition。 - 當
#turn_on
為true
,則對話流程不用等待使用者輸入而直接進入到@appliance
節點,因要透過@appliance
節點來持續評估使用者原本所輸入的資訊,故不用在等待新的輸入。
- 點擊
@appliance
節點下方 + 號 (Create alternative conversation),以建立同層節點。
Enter a condition | Watson says |
---|---|
❖ 輸入 true 後會出現一個選單,請選擇 true (create new condition)。 | ❖ 輸入 I'm sorry, I don't know how to do that. I can turn on music, headlights, or air conditioning. |
❖ 如果使用者輸入合法的 @appliance 資訊,則永遠不會到達此節點。 |
- 點擊
@appliance
節點右邊的 + 號 (Continue conversation),以建立子節點。 - 亦指使用者輸入了合法資訊。
Enter a condition | Watson says |
---|---|
❖ 輸入 @appliance 後會出現一個選單,請選擇 @appliance:music | ❖ 輸入 OK! What kind of music would you like to hear? |
❖ 如果 @appliance entity 是 music 或它的同義字 ( 定義於 Entities 頁面 ),則此節點將會被觸發。 |
- 點擊
@appliance
節點右上角的按鈕 ➙ Continue from ➙ 點擊@appliance:music
節點 ➙Go to condition
。 - 當
@appliance
為true
,則對話流程不用等待使用者輸入而直接進入到@appliance:music
節點,因要透過@appliance:music
節點來持續評估使用者原本所輸入的資訊,故不用在等待新的輸入。
- 點擊
@appliance:music
節點右邊的 + 號 (Continue conversation),以建立子節點。
Enter a condition | Watson says |
---|---|
❖ 輸入 @genre 後會出現一個選單,請選擇 @genre。 | ❖ 輸入 OK! Playing @genre. |
❖ 當使用者輸入任何與 @genre entity 相匹配的資訊,則此節點將會被觸發。 |
- 點擊
@genre
節點下方 + 號 (Create alternative conversation),以建立同層節點。
Enter a condition | Watson says |
---|---|
❖ 輸入 true 後會出現一個選單,請選擇 true (create new condition) | ❖ 輸入 I'm sorry, I don't understand. I can play classical, rhythm and blues, or rock music. |
❖ 如果使用者輸入合法的 @genre 資訊,則永遠不會到達此節點 |
28. 測試剛建立的 Conversation
- 點擊右上方的按鈕開啟對話視窗。
輸入 Play music 再按 Enter。
Watson 解析出來是
#turn_on intent
與@appliance:music
,並回覆 OK! What kind of music would you like to hear? 訊息。
- 輸入 rock 再按 Enter。
- 輸入 Play music 並輸入一個非法值。
29.建立 @appliance:music
的同層節點
- 點擊
@appliance:music
節點下方 + 號 (Create alternative conversation),以建立同層節點。
Enter a condition | Watson says |
---|---|
❖ 輸入 true 後會出現一個選單,請選擇 true (create new condition)。 | ❖ 輸入 OK, turning on the @appliance. |
❖ 使用者輸入一個合法訊息但不是音樂類別,則對話流程會到達此節點。 |
30. 測試剛建立的 Conversation
- 點擊右上方的按鈕開啟對話視窗。
輸入 lights on.
輸入 turn on the air.
輸入 play music 後再輸入 pop。
GitHub
參考資料
- http://www.ibm.com/watson/developercloud/doc/getting_started/gs-sdks.shtml
- https://watson-api-explorer.mybluemix.net/apis/conversation-v1#!/message/post_v1_workspaces_workspace_id_message
- http://www.ibm.com/watson/developercloud/conversation/api/v1/#send_message
- http://www.ibm.com/watson/developercloud/doc/conversation/tutorial_basic.shtml