如何从INTENT中提取参数以将其传递给webhook? [英] How to extract the parameter from INTENT in order to pass it to webhook?

查看:259
本文介绍了如何从INTENT中提取参数以将其传递给webhook?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设对话流中有一个名为 intent.direction 意图。此意图包含一些短语,例如: 指向PLACE_NAME的导航到PLACE_NAME 等。这里的 PLACE_NAME 是用户要去的任何地方的名称

Suppose there is an intent in Dialogflow named "intent.direction". This intent have some phrases like : "Direction to PLACE_NAME" or "Navigate to PLACE_NAME",etc. Here "PLACE_NAME" is the name of any place to which user wants to go.

>意图触发,我希望将< PLACE_NAME (即地点名称)传递到我的 WEBHOOK (index.js)。

When this intent is triggered, I want the "PLACE_NAME" i.e. name of place, to be passed to my WEBHOOK (index.js).

有什么办法吗?

-------------------更新的响应------------------

function makeDirection(app)
{
  if (!hasScreen)
  {
      app.ask('Sorry, try this on a screen device');
  }    
  else
  {
      //-----variables----
      var body2="";

      var placeName = app.getArgument( 'PLACE_NAME' );
      app.ask(placeName);

下面是测试的几张图片,我得到的最后一个意思是 PLACE_NAME 但是......

below are the few images of testing, I am getting the last word i.e. "PLACE_NAME" but....

推荐答案

是。

我假设您的Intent看起来像这样:

I assume your Intent looks something like this:

关于Intent设置要注意的重要事项是:

The important things to note about the Intent settings are:


  • 我们已经选择了每个训练短语中表示PLACE_NAME的部分

  • 我们已将它们设置为 @ sys.any 的实体类型。这将匹配任何东西。如果我们还有其他在这里有意义的实体类型(我们定义的实体类型或 @ sys.address @ sys.street-address ),我们可以改用这些。

  • 我们将参数名称更改为 PLACE_NAME
  • li>
  • 我们已经设置了必填字段。

  • We have selected the part of each training phrase that indicates the PLACE_NAME
  • We have set them to the entity type of @sys.any. This will match anything. If we have other entity types that would make sense here (either one we define or something like @sys.address or @sys.street-address), we could have used those instead.
  • We have changed the parameter name to PLACE_NAME.
  • We have set the field to be required.

我们还完成了诸如设置动作名称,然后通过网络挂钩打开实现。

We've also done things like set the action name to something and turned on fulfillment through a webhook.

在我们的网络挂钩中,我们将获取此Intent设置的参数值。

In our webhook, we'll get the values of the parameters that have been set by this Intent. How we do this will depend on what libraries we're using, if any.

既然您已经指出这是针对Google的操作,那么您可能正在使用它。使用AoG node.js库。如果是这样,我们可以使用类似

Since you've indicated this is for Actions on Google, it is likely you're using the AoG node.js library. If so, we can get the parameter using something like

var placeName = app.getArgument( 'PLACE_NAME' );

如果您正在读取JSON并使用Dialogflow V1,则可以从体内获取价值具有以下内容的对象:

If you're reading the JSON and using Dialogflow V1, you can get the value out of the body object with something like this:

var placeName = body.result.parameters['PLACE_NAME'];

如果您使用的是Dialogflow V2,则路径略有不同:

if you're using Dialogflow V2 instead, it is at a slightly different path:

var placeName = body.queryResult.parameters['PLACE_NAME'];

这篇关于如何从INTENT中提取参数以将其传递给webhook?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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