1
    var intent = args.intent;
    var number = builder.EntityRecognizer.findEntity(intent.entities, 'builtin.numer');

当我使用 findentity 时,如果答案正确或不正确,它会继续前进我如何在非内置实体上使用实体解析

    var location1 = builder.EntityRecognizer.findEntity(intent.entities, 'Location');
    var time = builder.EntityRecognizer.resolveTime(intent.entities);

当我使用解决时间时,它会一次又一次地询问,除非实体已解决;

    var alarm = session.dialogData.alarm = {
      number: number ? number.entity : null,
      timestamp: time ? time.getTime() : null,
      location1: location1? location1.entity :null
    };
    /*  if (!number & !location1 time)
     {} */


    // Prompt for number
    if (!alarm.number) {
        builder.Prompts.text(session, 'how many people you are');
    } else {
        next();
    }
},
function (session, results, next) {
    var alarm = session.dialogData.alarm;

    if (results.response) {
        alarm.number = results.response;
    }
4

1 回答 1

0

我相信我已经在 StackOverflow 上回答了这个问题:“ Botframework Prompt dialogs until user finish ”。

您需要创建一个迷你对话框,其中至少有两个瀑布步骤。您的第一步将采取任何措施args并将它们检查/设置为您的聊天机器人正在等待的潜在价值。它会提示用户验证这些值是否正确。如果没有args传入,或者数据无效,将提示用户提供聊天机器人正在等待的值。

第二步将获取用户对第一步的响应,并将值设置为session数据对象(如session.userDataor )或使用session.replaceDialog()session.beginDialog()session.conversationData重新启动对话框。

在您的主对话框中,您将修改使用您的步骤EntityRecognizers以包含一个开始您的迷你对话框的 if 语句。要触发 if 语句,您可以使用与此GitHub 示例或代码中所示相同的设计。此代码可能如下所示:

var location1 = builder.EntityRecognizer.findEntity(intent.entities, 'Location');

session.userData.location1 = location1 ? location1.entity : null;

if(!session.userData.location1) {
    session.beginDialog('<get-location-dialog>');
}
于 2017-04-16T20:26:48.463 回答