我正在构建一个机器人,到目前为止,这段经历对我来说充满挑战。这很可能是因为我来自 v1 并且我正在尝试以 v4 风格重建我的机器人,这似乎是一个完全不同的框架。
我发现那里有很多文档,但它被分为理论和实践,可能是由于您可以使用不同的开发框架(即 Node、C#)。但是不得不在这些文章之间来回切换无济于事,
经过一番折腾,我到了事情开始变得更体面的地步,但我仍然觉得还有很多改进的空间。我目前无法分享整个项目,但我在这里创建了最重要代码的要点:https://gist.github.com/jsiegmund/831d5337b1a438133991070daba8a27e
所以我对这段代码的问题/问题如下:
stepContext.PromptAsync
时我还需要提供卡片作为附件。对我来说感觉重复,但删除其中一个步骤失败。正常的样式提示对我不起作用,因为它不处理键/值而只处理字符串(参见数字 3)。好的,所以这些是我正在努力解决的一些问题。我正在到达那里并且它现在有效,但正如所说,我无法摆脱我做得不对的感觉。如果有人能对此有所启发,将不胜感激。
最佳答案
是的,从版本到版本有很多变化。你真的是说v1吗?! 😲 还是v3?
- 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.
本质上。瀑布数组中列出的步骤是您创建的方法名称的名称。基本上,这是您给出机器人应执行的步骤顺序的地方。提示是用于检索数据的类,并使用
AddDialog()
填充到(“主”)对话框中。并以唯一名称存储在对话状态中,以便可以正确检索它们。我明白您的观点,即在一个“调用”或声明中设置所有内容可能很简单,并且可能还有其他方法来实现这一点;但这就是我们得到的。
- 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 方面是正确的并获得正确的意图 + 实体(假设“预订”意图和实体 [“时间”和“客户”]),那么这应该是可行的。您将为这两个实体填充状态信息,然后后面的步骤(例如提示客户步骤)将跳过/绕过。
但是,您真正想做的是查看自适应对话框。它们是新的,使这种类型的场景更加动态和灵活。看这里:
- 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.
状态(对话|用户|等)将是管理这个的好地方。
- 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,因此是一个附件,您需要将其发送给用户/客户端。
你做的都是对的。再次;我建议查看自适应对话框,因为这是更新的技术和前进的方向。然而在其他方面;你走在正确的道路上!
关于botframework - 需要一些关于如何正确使用机器人框架 SDK 的指导,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63352812/