首页 > 解决方案 > Watson 助手 JSON 编辑器中的变量模式

问题描述

我在对话中为特定变量创建了一个模式。

类型:模式^[A-Za-z]{1,}$

我希望该变量的值仅是一个词,仅此而已。我只是不知道在 JSON 编辑器中的何处插入它。

   {
  "output": {
    "text": {
      "values": [
        "Nice to meet you $firstname. How can I assist you mate?"
      ],
      "selection_policy": "sequential"
    }
  },
  "context": {
    "firstname": "<? input.text.substring(0, 1).toUpperCase() + input.text.substring(1) ?>"
  }
}

标签: ibm-watsonwatson-assistant

解决方案


如果我理解正确,我认为您想要的是使用您的表达式创建一个基于模式的实体https://cloud.ibm.com/docs/services/assistant?topic=assistant-entities#entities-dictionary-overview

Watson Assistant 将识别您的模式的出现并将它们存储在“实体”数组中。然后,您可以使用“@myentitiy”语法在对话节点中构建条件,或者直接从“实体”数组访问它们。如果您只想第一次出现,请使用entities.get(0)


推荐阅读