简体   繁体   中英

IBM Watson Assistant: having trouble accessing defined entities from dialog JSON

I created an entity using the GUI named @ClientStates and added a list of states our client supports.

I need to see if the state entered by the user is in @ClientStates and if so print out some information.

I know that this can be done by creating a dialog node that checks for a match, but can it be done using JSON within the node? For example:

{
  "output": {
    "text": {
      "values": [
         "<? @ClientStates.contains($State)? 'Yes' : 'No ?>"
       ],
      "selection_policy": "sequential"
    }
  }
}

It seems that 'Yes' should be printed if the user input saved in the context variable $State is one of the states in @ClientStates and 'No' should be printed if it is not. However, the only output is 'No' for any input.

Further, I'm expecting the following code to print the list of states in @ClientStates, but it gives no output at all.

{
  "output": {
    "text": {
      "values": [
         "<? @ClientStates ?>"
       ],
      "selection_policy": "sequential"
    }
  }
}

Why can't I access the predefined entity @ClientStates from within the dialog JSON?

You can only access the entities in dialog only if its part of input. And 2nd thing is there is no need to use 'contains' for checking if input contains this entity or not.

use:

<? @ClientStates ? 'Yes' : 'No ?>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM