本文介绍了机器人响应后触发意图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

dialogflow实现代码示例可以按如下所示返回意图中的响应。

The dialogflow fulfillment code sample can return response in intent as follow.

function welcome(agent) {
  agent.add(`Welcome to agent!`);
}

假设我想在此之后立即触发另一个意图名称 faq 没有任何用户输入。怎么做到呢?我期待以下内容,但找不到任何文档。

Suppose that I want to trigger another intent name "faq" right after that without any user input. How can it be done? I am expecting something as follow but could not find any documentation.

function welcome(agent) {
  agent.add(`Welcome to agent!`);
  agent.triggerIntent('faq');
}

我看着,但仍然无法实现它。

I look at the custom event documentation but still unable get the idea to implement it.

对话示例:

User A: Hi
Bot: Welcome to agent!
Bot: Please pick FAQ to see detail:
1) FAQ 1
2) FAQ 2
3) FAQ 3
User: Show FAQ
Bot: Please pick FAQ to see detail:
1) FAQ 1
2) FAQ 2
3) FAQ 3


推荐答案

通常,您不能这样做。

In general, you can't do this. But you also don't need to.

请记住,一个Intent代表用户所说的话,而不是您如何回应。因此,您的欢迎意向可以回复欢迎信息,然后是FAQ提示。第二个Intent可以仅通过FAQ提示进行答复。

Remember that an Intent represents what the user has said and not how you respond to that. So your welcome Intent can reply with a welcome message, and then the FAQ prompting. And a second Intent can reply with just the FAQ prompting.

最简单的方法是将所有答复都包含在实现中,并为欢迎意图和常见问题意图调用将相同的函数发送回提示答复。

The easiest way to do this is to have all your replies in your Fulfillment, and have both the handler for the "Welcome" Intent and the "FAQ" Intent call the same function that sends back the prompting reply.

这篇关于机器人响应后触发意图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-30 16:02