1
votes

I have an entity defined as

@code
- @code:type_1 = pattern 'Y(\d{3})'
- @code:type_2 = pattern 'order number(\d{3})'
- @code:type_3 = pattern 'CZ(\d{3})'

I am trying to capture the following context values like so

{
  "context": {
    "type_3s": "<? @code.filter(\"c\", \"c['value'] == 'type_3'\").joinToArray('%e.groups[1]%') ?>"
  }
}

So that for input

Please delete codes CZ123, CZ456, and CZ789, my final context looks like this: $type_3s =[123,456,789]

Currently getting the error

SpEL evaluation error: Expression [ entities['code'].filter("c", "c['value'] == 'type_3'").joinToArray('%e.groups[1]%') ] at position 63: EL1004E: Method call: Method joinToArray(String) cannot be found on ArrayList type

In the above example, code.values evaluates to:

@code.values =["type_3", "type_3", "type_3"]

Any help in achieving the desired context would be greatly appreciated, thank you so much!

1
Could you add how @code.values looks like, i.e. its value? - data_henrik
@data_henrik @code.values for the above string would be @code.values = ["type_3", "type_3", "type_3"] - njz2104

1 Answers

0
votes

My recommendation would be to take a look at the Watson Assistant entity syntax. .value returns the identified entity which would be type_3. You would need to use .literal to access what was really entered.

In the tutorial on building a database-driven Slackbot a similar method is used to access what was entered for a location entity. The code is on GitHub.