最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

botframework选择无效的响应类型

运维笔记admin15浏览0评论

botframework选择无效的响应类型

botframework选择无效的响应类型

我使用nodejs SDK来创建我的机器人与MSFT botframework。代码段如下:

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
    }
}

我有两个问题:

  1. 我想导航到另一个对话框Flow,以防用户输入除选项之外的任何内容(“AAA”,“BBB”,“CCC”)。那可能吗?
  2. 我想改变重试提示每次让我们说从列表中选择话语。那可能吗?
回答如下:

我想导航到另一个对话框Flow,以防用户输入除选项之外的任何内容(“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);
  }

我想改变重试提示每次让我们说从列表中选择话语。那可能吗?

是的,这是可能的。根据choice定义,我们可以设置扩展IPromptChoiceOptions的选项扩展[IPromptOptions][2],我们可以找到retryPrompt?: TextOrMessageType;,挖掘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会随机选择一个。请尝试以下方法:

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']
        });
发布评论

评论列表(0)

  1. 暂无评论