我有一个 dialog
,它有多个提示( Prompts.text
, Prompts.number
, Prompts.Choice
, Prompts.confirm
) . 虽然 Prompts.choice
和 Prompts.confirm
似乎有内置验证,但如何验证 Prompts.text
?
我已经完成了这个帖子How to handle wrong input from the user?但是通过将文本转换为选择来纠正它 .
此外,我不想重新启动整个对话框,因为它从create custom prompts to validate input开始询问问题表格 .
这是我的对话框的较短版本:
bot.dialog('/getDetails', [
function (session, args, next) {
let options = {
retryPrompt: 'The response id invalid'
}
builder.Prompts.text(session, 'What is your full name?', options);
//passing options as argument works for Prompts.choice, which seems an inbuilt validation
},
function (session, results, next){
var name = session.dialogData.name;
//How to to reprompt if user does not enters its full name?
if (results.response) {
name.fullname = results.response;
}
builder.Prompts.text(session, 'Can you please provide your country name?');
},
function (session, results) {
var name = session.dialogData.name;
//How to reprompt only last Prompts.text if user enter an invlid value?
if (results.response) {
name.text = results.response;
}
}
}]).triggerAction({
matches: 'GetDetails',
})
1 回答
这是我如何通过DialogAction.validatedPrompt解决它