Google 上的操作:HTTP POST 用户实体 v2

Actions on Google: HTTP POST User Entities v2

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

使用文档中的 url: 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 服务器中,但错误提示枚举是保留关键字。

5 月 17 日更新: request.post( link,

  {
    "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)
          }
      }
  );

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

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

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

这里的enum(EntitiyOverrideMode)表示这个值应该是参考文献here.

中提供的任何EntitiyOverrideMode枚举值