需要一些关于如何正确使用机器人框架 SDK 的指导

Need some guidance on how to properly use bot framework SDK

我正在构建一个机器人,到目前为止,这段经历对我来说充满挑战。这很可能是因为我来自 v1,我正在尝试以 v4 风格重建我的机器人,这看起来是一个完全不同的框架。

我发现那里有很多文档,但它们被分为理论和实践,这可能是由于您可以使用不同的开发框架(即 Node、C#)。但是不得不在这些文章之间来回切换是没有帮助的,

经过相当多的折腾,我发现事情开始变得更像样了,但我仍然觉得还有很多改进的余地。我现在不能分享整个项目,但我在这里创建了最重要代码的要点:https://gist.github.com/jsiegmund/831d5337b1a438133991070daba8a27e

所以我的 issues/questions 使用此代码如下:

  1. 添加对话框的方式,主要是需要添加检索答案的提示,令人困惑。我明白了,但不知道内部运作。例如:我现在有以相应对话步骤的相同方法名称命名的提示,这是它应该工作的方式吗?按照惯例,似乎有一些神奇的代码将所有东西连接在一起?当瀑布步骤也包含提示时,对我来说更有意义。

  2. 向对话框提供信息以使其可以跳过步骤的正确方法是什么?我在主对话框中设置了 LUIS 意图,然后打开此对话框进行小时预订。假设我的用户说“我想为客户 X 预订 8 小时”,我希望对话框将金额预填充为 8,将客户预填充为 X。

  3. customer/project 解析可能不是这里的标准要求。这些来自第三方应用程序,通过 API/SDK 检索。因此,基于登录用户,我需要转到该应用程序并检索该用户的数据。这返回 key/value 对,其中键是 GUID。我不希望用户输入 GUID,所以我用客户的名字创建了这些操作按钮,但是为了将 ID 值放入下一步,现在 'writes' 聊天中的 GUID 而不是客户名称。使用名称很棘手,因为我不能完全依赖它们的独特性。此外,为了选择项目,我需要客户 GUID 并保存最终条目,我还需要 ID。但我不想让用户看到那些。

  4. 我现在制作卡片的方式对我来说也很奇怪。我首先需要为卡片添加一个对话框,稍后在调用 stepContext.PromptAsync 时我还需要将卡片作为附件提供。对我来说感觉重复,但删除其中任何一个步骤都失败了。普通样式提示对我不起作用,因为它不处理 key/value 而只是字符串(参见数字 3)。

好的,这就是我正在努力解决的一些问题。我到达那里并且它现在可以工作,但正如所说我无法摆脱我做得不对的感觉。如果有人能对此有所启发,我们将不胜感激。

是的,每个版本都有很多变化。你真的是说v1吗?!还是 v3?

  1. The way to add dialogs and mainly the need to add prompts for retrieving the answers is confusing. I get the idea, but not really the inner workings. For instance: I now have the prompts named after the same method names of the corresponding dialog step, is that the way it's supposed to work? There seems to be some magic code linking everything together, by convention? It would make much more sense to me when the waterfall steps would also include the prompts.

本质上。瀑布数组中列出的步骤是您创建的方法名称的名称。基本上,这是您给出机器人应该完成的步骤的 order 的地方。提示 类 用于检索数据,并使用 AddDialog() 填充到(“主”)对话框中,并以唯一名称存储在对话框状态中,以便可以正确检索它们。我明白你的观点,即在一次“调用”或声明中设置所有内容可能很简单,并且可能还有其他方法可以实现这一点;但这就是我们得到的。

  1. What's the right way of feeding the dialog with information so it can skip steps? I've got LUIS intents set-up in a main dialog which then open up this dialog for hour booking. Suppose my user says "I'd like to book 8 hours on customer X", I'd like the dialog to pre-populate the amount to 8 and the customer to X.

通常,步骤使用之前的步骤值来回复、执行或继续。在简单的场景中,可以通过检查这些值的状态来跳过步骤。在 multiturn sample 中,如果用户不想提供他们的年龄,它会继续下一步,然后检查值并跳过该步骤(实际上 不会 跳过它,它报告没有给出年龄,但你可以继续而无需任何回复)。假设 LUIS 方面的事情是正确的并且获得了正确的意图 + 实体(假设 'booking' 意图和实体 ['time' 和 'customer']),那么这应该是可行的。您将为这两个实体填充状态信息,然后后面的步骤(比如提示客户步骤)将只是 skip/bypass.

但是,您真正想做的是查看自适应对话框。它们是新的,使这种类型的场景更加动态和灵活。看这里:

  1. The customer / project resolving is maybe a not-so-standard requirement here. These come from a third party application, retrieved through API/SDK. So based on the logged in user I need to go out to that application and retrieve the data for this user. This comes back in key/value pairs, where the key is a GUID. Obviously I don't want the user to type in GUIDs, so I have created these action buttons with the names of the customers, but to get the ID value into the next step it now 'writes' the GUID in the chat instead of the customer name. Using the name is tricky as I can't fully rely on those being unique.

我不是 100% 确定这部分。让我调查一下,然后回复您。

Also, for selecting the project I need the customer GUID and saving the final entry I also need the ID's. But I don't want the user to see those.

状态(对话|用户|等)将是管理它的好地方。

  1. The way I now have the cards built is also weird to me. I first need to add a dialog for the card, and later when calling stepContext.PromptAsync I need to supply the card as an attachment as well. Feels duplicate to me, but removing either one of the steps ends in failure. The normal style prompt doesn't work for me as that doesn't handle key/value but just strings (see number 3).

不,没错。我知道这感觉很奇怪,但这就是做到这一点的方法。基本上,除了简单的文本之外的任何内容都将是附件。卡片是 JSON,因此是一个附件,您需要将其发送到 user/client。

你做的一切都是正确的。再次;我建议查看自适应对话,因为这是新技术和进步。然而在其他方面;你走在正确的道路上!