2016-11-05 40 views
4

請考慮以下是對話框。如何在Node.js中定義bot的默認行爲?

bot.dialog('/beer', [ 
    function (session) { 
     builder.Prompts.number(session, "How many mugs would you like?"); 
    }, 
    function (session, results) { 
     if (results.response && results.response.entity != '(quit)') { 
      // Launch demo dialog 
      session.endDialog("Beer" + (results.response == 1 ? " is on the" : "s are on their") + " way, enjoy!"); 
     } else { 
      // Exit the menu 
      session.endDialog("Goodbye, See you later.."); 
     } 
    } 
]); 

當如果在文本(例如「測試」),而不是一個有效的數字用戶類型,機器人給出像default_number響應此獲取提示給用戶。

的數量相同的默認錯誤消息是default_number,選擇default_choice,文字default_error,等等。我已經嘗試了不同的方式來弄清楚如何採取控制權和定義默認行爲的東西像機器人說「我不認識它,請再試一次」而不是給出錯誤,這對用戶沒有任何意義。

任何人都可以對此有所瞭解嗎?

參考鏈接 https://docs.botframework.com/en-us/node/builder/chat/prompts/#promptsnumber

回答

3

(更好的答案總是歡迎。)

最後搜索了很多後發現了以下的東西。

在模擬器默認情況下它處理錯誤消息&展示的東西

「哎呀,出了點問題,我們需要重新開始。」

「我不明白。」

但是在Direct Line APIs/Skype等其他頻道上。實際BOT響應越來越顯示它就像「default_error」,「default_choice」等。

要更改默認的錯誤信息,我們可以簡單地添加一個名爲「BotBuilder.json」裏面的文件夾

BotProject/locale/<languageCode>/BotBuilder.json 

所以文件包含了覆蓋默認的錯誤如下短信:

{ 
    "default_error": "I did not recognize it. Please try again." 
} 


更新:希望這是覆蓋所有可能的列表。

{ 
    "default_text": "I didn't understand. Please try again.", 
    "default_number": "I didn't recognize that as a number. Please enter a number.", 
    "default_confirm": "I didn't understand. Please answer 'yes' or 'no'.", 
    "default_choice": "I didn't understand. Please choose an option from the list.", 
    "default_time": "I didn't recognize the time you entered. Please try again using a format of (MM/DD/YYYY HH:MM:SS).", 
    "default_file": "I didn't receive a file. Please try again.", 
    "default_error": "Oops. Something went wrong and we need to start over." 
} 
相關問題