【问题标题】:Actions on Google: HTTP POST User Entities v2Google 上的操作:HTTP POST 用户实体 v2
【发布时间】:2018-05-17 12:31:04
【问题描述】:

我希望为每个用户创建一个用户实体。

使用文档中的此网址: https://dialogflow.googleapis.com/v2/{parent=projects//agent/sessions/}/entityTypes

和 POST 正文:

{
  "name": myString,
  "entityOverrideMode": enum(EntityOverrideMode),
  "entities": [
    {

      {
        "value": "myHistory",
        "synonyms": [
          "history",
          "Google\u0027s history",
          "past",
          "Google\u0027s past",
          "history of Google"
        ]
      }   
    }
  ]
}

这是正确的做法吗?

我已经在我的 NodeJS 服务器中插入了这段代码,但是 ERROR 说 enum 是一个保留关键字。

更新 17 可能: 请求.post( 链接,

  {
    "name": entityname,
    "entityOverrideMode": ENTITY_OVERRIDE_MODE_SUPPLEMENT,
    "entities": [
      {

              "value": "barbie",
              "synonyms": [
                "barbie",
                "barbiedoll",
                "barb",
                "barbie\u0027s doll",
                "doll"
              ]

      }
    ]
  },
      function (error, response, body) {
          if (!error && response.statusCode == 200) {
              console.log(body)
          }
      }
  );

其中链接是 'https://dialogflow.googleapis.com/v2/' + conv.body.session + '/entityTypes';

and entityname = conv.body.session + '/entityTypes/device_name'

【问题讨论】:

    标签: actions-on-google dialogflow-es


    【解决方案1】:

    enum 是 ES5 和 ES6 中的保留关键字。

    这里的enum(EntitiyOverrideMode)表示该值应该是参考here.中提供的任何EntitiyOverrideMode枚举值

    【讨论】:

    • 嗨@Taylor Caldwell,我在我的POST请求中使用了“entityOverrideMode”:ENTITY_OVERRIDE_MODE_SUPPLEMENT,但firebase抛出了一个错误“ENTITY_OVERRIDE_MODE_SUPPLEMENT未定义”。我应该把它作为一个字符串吗?
    • 是的,要成为有效的 JSON,它必须是 String 值。
    • 是的,没错。我现在打印出这个错误: body: '{\n "error": {\n "code": 401,\n "message": "Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or其他有效的身份验证凭据。请参阅developers.google.com/identity/sign-in/web/devconsole-project.",\n "status": "UNAUTHENTICATED"\n }\n}\n' }
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-11-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多