如何通过 watson-developer-cloud 库从 Watson 的对话服务中检索特定的配置文件变量

How to retrieve specific profile variables from Watson's Dialog service via the watson-developer-cloud library

Watson's Dialog 服务检索配置文件变量时,有一个名为 name 的参数这允许您控制检索哪些变量。如果此参数为空,则返回与指定 client_id 关联的所有变量。否则,只返回name中指定的变量。

我终于想出了如何在直接 GET 到 REST API 上指定多个变量名称(给它们一个相同的名称,比如 &name=var1&name=var2),但我做不到了解如何通过 watson-developer-cloud 库执行此操作。似乎无论我如何在 dialog.getProfile() 函数调用中指定名称,它总是 returns all 变量.

有人能告诉我怎么做吗?我不想每次都把它们都取下来,然后在它们中搜索我想要的那个。

库中有一个 bug 阻止 name 被发送到服务。

请更新库

npm install watson-developer-cloud

并尝试下面的示例

var params = {
  dialog_id: '<dialog id here>',
  client_id: '<client id here>',
  name: ['var1', 'var2']
};

dialog.getProfile(params, function(err, response){
  console.log(response)
});