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

后端 未结 1 496
深忆病人
深忆病人 2021-01-22 00:54

I\'m creating sample application using Watson conversation API in nodejs. I\'m trying to get username and send them to Watson and then I want to say hello \"$username\", also I

相关标签:
1条回答
  • 2021-01-22 01:42

    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

    0 讨论(0)
提交回复
热议问题