Using Watson conversation, how to handle customer, account number etc

北慕城南 提交于 2019-12-01 23:40:47

You can use context variables for that.

To extract the name, request the name in 1º node, and in the next node, add this JSON:

{
  "context": {
    "name": "<? input.text ?>"
  },
  "output": {
    "text": {
      "values": [
        "Hello $name."
      ],
      "selection_policy": "sequential"
    }
  }
}

The input.text capture all user has typed.

You can use $ for set and get the context variable with the name: $name will show what user has typed.

In other case, if user typed my name is XXXXX, you can use regex inside your context variable. Check this example for use REGEX inside context variables:

   "name" : "<? input.text.extract('^[A-Z][-a-zA-Z]+$') ?>"

@MichelBida did one example with regex, but with another request for user, check this link.

EDIT:

Use:

context.myproperty = "Hello World";

And now have the System Entity @sys-person, this entity extracts names from the user's input. Names are not normalized by the system, so "Will" is not treated as "William", nor vice versa, see official documentation. This entity can be active within Entity -> System Entities -> @sys-person

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!