我正在使用MS bot構建器node.js SDK。在最近一次更新之前,當提示重試時,它將與重試提示一樣向用戶發送相同的消息文本。重試提示自定義
但是,現在它正在系統中發送默認文本消息,即「我不明白,請再試一次」。但是,我希望重試提示始終與原始消息相同,並且如果可能的話希望將其應用於全局,這意味着我不想爲我發送給用戶的每個提示自定義重試提示。
我一直在環顧四周,但還找不到方法。
謝謝!
我正在使用MS bot構建器node.js SDK。在最近一次更新之前,當提示重試時,它將與重試提示一樣向用戶發送相同的消息文本。重試提示自定義
但是,現在它正在系統中發送默認文本消息,即「我不明白,請再試一次」。但是,我希望重試提示始終與原始消息相同,並且如果可能的話希望將其應用於全局,這意味着我不想爲我發送給用戶的每個提示自定義重試提示。
我一直在環顧四周,但還找不到方法。
謝謝!
您可以修改提示以自動將提示設置爲重試提示。 Prompts
interface顯示瞭如何將參數傳遞到基類Prompt
類,因此我們可以通過訪問Prompts
中的方法來修改此提示行爲。
這裏有一個如何與Prompts.confirm
const promptPrefix = 'BotBuilder:prompt-';
bot.dialog('/', [
(session) => {
builder.Prompts.confirm(session, 'Say yes or no');
},
(session, args) => {
session.endConversation('You said: ' + session.message.text);
}
]);
builder.Prompts.confirm = (session, prompt, options) => {
var args = options || {};
args.prompt = prompt || args.prompt;
// If options.retryPrompt was passed in use this, otherwise use prompt
args.retryPrompt = args.retryPrompt || args.prompt;
session.beginDialog(promptPrefix + 'confirm', args);
};
修改後的Prompts.confirm做它在行動的例子:
一種選擇是將重試提示作爲選項發送到提示。例如:
builder.Prompts.number(session, "What's the number?", {
retryPrompt: "What's the number?"
});
但是,您將不得不在每次提示時都進行配置。
感謝您對本非常有用的職位。我有一個類似的問題,但與builder.Prompts.choice。你能否留下你的想法? https://stackoverflow.com/questions/48893767/how-to-customize-prompt-choice-microsoft-botbuilder-sdk – gpsugy