如何一目了然地设置上下文和跟进事件? [英] How do I set context and followup event in one intent?

查看:112
本文介绍了如何一目了然地设置上下文和跟进事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图通过跟踪事件跳转到一个随机问题,同时将问题编号存储在上下文中。但是dialogflow只跳到事件而没有存储问题号。有没有一种方法可以跟进事件并以一种意图存储上下文?

I am trying to jump to a random question with followup event, and at the same time store the question number in the context. But dialogflow only jumps to the event without storing the question number. Is there a way to do followup event and store a context in one intent?

app.intent('Quiz - random', (conv) => {
    let rand = Math.floor(Math.random() * quiz_len) + 1;
    conv.data.current_qns = rand;

    conv.followup(`quiz-question${rand}`);
});


推荐答案

不是真的。使用 conv.followup()的目的是使它好像新的Intent是用户实际触发的那样。请记住-意图表示用户在说什么 不是您要回复的内容。您可以 在重定向中包含一个参数,我想您可以使用它来发送问题,但这仍然等同于用户发送的参数。

Not really. The point of using conv.followup() is to make it as if the new Intent is the one that was actually triggered by the user. Remember - Intents represent what the user is saying not what you're replying with. You can include a parameter with the redirect, which I guess you can use to send the question, but this still would be the equivalent of a parameter sent by the user.

尚不清楚为什么您觉得需要直接使用其他Intent。只是在提问中提出问题吗?继续,在您位于的Intent处理程序中询问该问题,并将其直接存储在上下文中。

It isn't entirely clear why you feel you need to direct to a different Intent. Is it just to ask the question as part of the reply? Go ahead and ask it in the Intent handler you're in and store the number in the context directly.

更新

您已在注释中表示要构建事物,因此您有一个随机分派器,然后将其重定向到一个问问题的意图,并且该意图具有后续意图接受正确的答案(并可能接受错误的答案)。

You've indicated in the comments that you want to structure things so you have a "random dispatcher" that then redirects to an Intent to ask a question, and that Intent has a Followup Intent that accepts the right answer (and possibly ones that deal with wrong answers).

这需要您为所有各种问题以及条件建立更多的意图关于每个问题。这要求您每次想添加新问题时都重新构建此结构。

This requires you to build a lot of extra Intents for all the various questions, and then the conditions on each question. This requires you to re-build this structure every time you want to add a new question.

Dialogflow很好地导航了对话的结构-因此您不必无需使用它来浏览特定的问题,答案和答案。记住-意向模型是对用户所说的内容进行概括,而不是我们的代理如何响应。

Dialogflow works very well to navigate the structure of a conversation - so you don't need to use it to navigate specific questions, answers, and responses. Remember - Intents model what a user says in broad terms, not how our agent responds.

这里的结构可能会更好:

Here is a structure that might work better:


  1. 有一个Intent可以处理用户询问随机问题。为此的意图实现(即-Webhook中的处理程序函数)执行以下操作:


    • 选择一个问题

    • 设置上下文以指示正在询问的问题

    • 将上下文和问题发送给用户


  • 为此您的处理程序会比较答案。

  • 如果正确,则清除上下文,这样说,然后询问如果他们想要另一个问题。 (然后,这将循环到步骤1中指定的Intent。)

  • 如果不正确,请确保上下文仍然有效,并告知他们错误。可能增加一个计数器,这样就不会让他们无限期地猜测。

意味着您只建立两个Intent来处理问题本身。您应该再添加一些。以下是一些要考虑的问题:

This means you're only building two Intents that handle the question itself. You should add a few more. Here are a few to think about:


  • 如果用户什么都不说怎么办? 无输入方案的处理方式应与错误答案的处理方式不同。

  • 如果您要问多项选择题,也许您将使用列表并需要处理列表响应

最后,如果您使用列表,则可能想做点花哨的事情,并使用Dialogflow的API设置会话实体输入该问题。这样,您就可以为正确和不正确的内容设置期望值(使用一些别名),然后在上下文中使用后备意图来表示用户所说的内容没有任何意义。

Finally, if you're using a list, you may want to do something fancy and use Dialogflow's API to set a Session Entity Type for just that question. This allows you to set what you're expecting (with some aliases) for what is correct and incorrect, and then use a Fallback Intent for the context to say that what the user said didn't make sense.

这篇关于如何一目了然地设置上下文和跟进事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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