问题
I am using MS bot builder node.js SDK. Before one of the recent updates, when the prompt is retried, it was sending the same message text to the user as the retry prompt.
However, now it is sending the default text message in the system, which is "I didn't understand.Please try again". However, I want retry prompts always be the same as the original message and if possible want to apply this globally, meaning I don't want to customize retry prompt for every prompt I am sending to the user.
I had been looking around, but couldn't find a way yet.
Thanks!
回答1:
You can modify the prompts to automatically set the prompt as the retry prompt. The Prompts interface shows how the args are passed in to the base Prompt
classes, so we can modify this prompt behavior by accessing the method in Prompts
.
Here's an example of how to do it with 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);
};
The modified Prompts.confirm in action:
回答2:
One option is to send the retry prompt as an option to the prompt. For example:
builder.Prompts.number(session, "What's the number?", {
retryPrompt: "What's the number?"
});
But you will have to configure that on every prompt.
来源:https://stackoverflow.com/questions/45479636/retry-prompt-customization