Node.js botframework选择键入的响应无效
我正在使用nodejs SDK创建带有MSFT botframework的bot。 代码片段如下所示:Node.js botframework选择键入的响应无效,node.js,botframework,Node.js,Botframework,我正在使用nodejs SDK创建带有MSFT botframework的bot。 代码片段如下所示: function(session, args, next){ builder.Prompts.choice(session, "Please select one of the options:", ['AAA', 'BBB','CCC'], {retryPrompt: "Invalid choice, Please pick below listed choices",
function(session, args, next){
builder.Prompts.choice(session, "Please select one of the options:", ['AAA', 'BBB','CCC'], {retryPrompt: "Invalid choice, Please pick below listed choices",
listStyle: builder.ListStyle.button,
maxRetries: 1
});
},
function(session,results){
if (results.response) {
//Do something
}
}
我有两个问题:
当您可以在
retryPrompt
中调用函数时,您可以同时执行以下两项操作:
builder.Prompts.choice(
session,
'This is just a question?',
'Yes|No',
{ retryPrompt: particularRetry() }
);
在上述功能中,您可以在specialretry
功能中执行您想要的操作。
例如,对于第二个问题,您可以使用新选项调用新的propmt。
您可以在中查看更多详细信息
如果用户键入选项(“AAA”、“BBB”、“CCC”)以外的任何内容,我希望导航到不同的对话框流。可能吗
是的,有可能。您可以定义多个对话框,其中包含与选项相关的瀑布式步骤。比如:
bot.dialog('AAA',[...])
并利用replaceDialog
将用户重定向到新的对话框流:
(session,result)=>{
//result.response.entity should be one of string `AAA`,`BBB`,`CCC`
session.replaceDialog(result.response.entity);
}
我想每次都改变retryPrompt,比如说从列表中选择话语。可能吗
是的,有可能。根据定义,我们可以设置选项extendsIPromptChoiceOptions
来扩展[IPromptOptions][2]
,我们可以发现retryPrompt?:TextOrMessageType
,深入源代码以了解文本或消息类型的定义:
/**
* Flexible range of possible prompts that can be sent to a user.
* * _{string}_ - A simple message to send the user.
* * _{string[]}_ - Array of possible messages to send the user. One will be chosen at random.
...
...
*/
export type TextOrMessageType = string|string[]|IMessage|IIsMessage;
因此,我们可以为retryPrompt
设置一个字符串列表,bot生成器将随机选择一个。请尝试以下操作:
builder.Prompts.choice(session, "Please select one of the options:", ['AAA', 'BBB', 'CCC'], {
listStyle: builder.ListStyle.button,
maxRetries: 1,
retryPrompt:['utterance 1','utterance 2','utterance 3','utterance 4']
});
谢谢你的帮助。hi@AIMCognitiveGurgaonBigData,很高兴看到你的好消息,如果它解决了你的问题,你可以将它标记为答案,这也将有利于与你面临相同问题的其他社区。谢谢你的投入。