如何在Watson Conversation中保存数据?

问题描述 投票:0回答:1

我需要在Watson Conversation中保存数据,例如:

-Watson说:你好,告诉我你的名字

- 我说:我的名字是艾萨克

-Watson说:好的Isaac,晚安!**

我怎样才能保存这个值?当他认出艾萨克的名字时,没有告诉沃森说。只需保留“名称”的数据并显示它。并且能够使用我在其他节点中保留Isaac名称的变量

非常感谢你!

javascript node.js watson-conversation watson
1个回答
1
投票

在这种情况下,你可以在Watson Conversation中使用context variables或@sys-person(检查Supported languages)来做到这一点。

带正则表达式的上下文变量:

要获取name值,您需要使用Regex从用户输入中提取。例如,在所有想要显示用户名称的节点中设置它。

{
  "context": {
    "name": "<? input.text.extract('yourRegextoExtractName')?>"
  },
  "output": {
    "text": {
      "values": [
        "Hi $name, how do you do?"
      ],
      "selection_policy": "sequential"
    }
  }
}

请注意,我使用syntax设置上下文变量:$name。因此,只需将要显示名称的所有节点放入相同的语法即可设置名称上下文变量。

@sys-person - 系统实体。

您还可以激活@sys-person系统实体,并使用我的示例在下面保存日期。请注意,这是BETA。

使用@sys-person,active on:Entities - > System entities - > @sys-person,请参阅我的图片anothers actives system-entity:enter image description here

你的对话条件将是这样的:

enter image description here

结果:

enter image description here

  • @sys-person Supported languages;
  • 尝试验证上下文变量在this link中的工作方式,以及如何在WCS here中使用正则表达式。
  • 尝试通过Watson Conversation了解有关Expression language methods的更多信息。
  • 验证正则表达式如何工作(正则表达式)here
© www.soinside.com 2019 - 2024. All rights reserved.