如何共享Webhook代码和意图一起工作? [英] How to share webhook code and intents works together?

查看:72
本文介绍了如何共享Webhook代码和意图一起工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在与dialogflow一起使用一个聊天机器人来租用其他建筑物(在我的情况下称为FMR)。我有一个新FMR意图,如下图所示:

I' m working with dialogflow to have a chatbot for renting different buildings(in my case called FMRs). I have a "New FMR" intent as shown in the following picture:

您看到的此FMR根据其设施的不同,租金价格也不同。我有一个graphql数据库来存储FMR及其参数。我使用webhook并编写了一段Java脚本代码来获取FMR列表。每当用户说建立一个名为TEST的新FMR,租金为两居室$ 1500时,我的代码都会检查数据库中是否存在FMR名称(TEST)。如果存在,我们应该询问用户是否要编辑存在的FMR的参数,如果不存在,则将在数据库中创建新的FMR。我的问题是数据库中存在FMR的第一部分,因为我只能在自己的代码中检查它的存在,我可以在哪里要求用户编辑已存在的FMR或否,并得到他/她的答复以继续工作?我如何才能将其连接到我的代码并正确实现上述方案?还是在用户对有关编辑已存在的FMR的问题说是或否之后,如何触发代码中的子意图被执行?抱歉,冗长的描述,并提前感谢您的帮助

As you see this FMR has different rent prices according to its facilities.I have a graphql database to store FMRs and their parameters. I used webhook and wrote a piece of java script code to get the list of FMRs. Whenever user says "Set up a new FMR called TEST with rent two bedroom at $1500" my code checks whether the FMR name(TEST) exists in the database or not.If it exists we should ask the user if she/he wants to edit the parameters of existed FMR, and if it doesn't exist, the new FMR will be created in database. My problem is with the first part that FMR exists in database.As I only can check its existence in my own code, where can I ask the user to edit the existed FMR or no and get his/her response to continue the work? How can I have a sub-intent to connect it to my code and have the above scenario correctly? Or how can I trigger a sub-intent in my code to be executed after user says "Yes" or "no" to my question about "editing existed FMR"? Sorry for long description and thanks in advance for your help

推荐答案

我仍然对对话流程的外观感到困惑,但是听起来像是这样:

I'm still confused about how this conversation flow should look, but it sounds like it would be something like this:


  • 用户说:创建一个名为 name的新FMR with ...

  • User Says: "Create a new FMR named name with..."

如果名称不存在,请保存数据,并回复已命名为 name 的FMR。

If "name" does not exist, save the data, reply with "The FMR named name has been created" and close the conversation.

如果存在名称,请回答: 名称 FMR存在。是否要对其进行编辑?

If "name" exists, reply: "The name FMR exists. Do you want to edit it?"


  • 用户说:否

  • User says: "no"

回复:它应命名为什么?

Reply: "What should it be named?"

用户说新的名称和处理过程如上所述。

User says the new name and processing repeats as above.

用户说:是

保存数据,并回复名为 name 的FMR已更新,然后关闭对话。

Save the data, reply with "The FMR named name has been updated", and close the conversation.

在您的履行代码中,是否需要询问是/否,您还可以使用上下文进行回复,并使用足够的信息设置参数,以便您记住用户在下一次调用您的履约时已经说过该FMR。

In your fulfillment code, if you need to ask the yes/no question, you'd also reply with a Context, setting the parameters with enough information so you can remember what the user has already said about this FMR the next time your fulfillment gets called.

然后您可以创建针对是和否的关注意图。给每个人一个不同的动作设置,这样您就可以在实现方面与众不同。您还需要另一个具有此Context作为输入上下文的Intent,并具有与用户将如何指定名称(例如,带有名为@ sys.any类型的名为 fmr-name的参数)相匹配的示例短语。

You can then create followup Intents for the "Yes" and "No" responses. Give each one a different Action setting, so you can differentiate them in your fulfillment. You'll also need another Intent that has this Context as the input context and has sample phrases that match how the user will specify the name (ie - with a parameter named "fmr-name" of type @sys.any) - this can have the same Action setting as your original Intent.

再次调用您的履行时,您会知道他们是否回答是或否(通过检查操作)。如果他们说是,则您具有他们已经说过的先前信息,可以保存并退出。

When your fulfillment is called again, you know if they've responded yes or no (by checking the Action). If they've said "yes", you have the previous information they already said and can save and exit.

如果他们说否,您将提示输入新名称,然后再次设置上下文,其中包含在收到回复时需要记住的信息。当他们确实答复时,您将检查新名称的参数并使用上下文中的值。

If they've said "no", you'll prompt for the new name and set the Context again with the information you need to remember when you get a reply. When they do reply, you'll check the parameters for the new name and use the values from the context.

这篇关于如何共享Webhook代码和意图一起工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆