1
votes

I have created an entity called @material_number and this entity has 3 values which are provided below with their respective patterns:

num1 with the pattern (\d{3}\.){1}\d{3}

num2 with the pattern (\d{3}\.){2}\d{3}

num3 with the pattern (\d{3}\.){3}\d{3}

In a dialogue node, if the bot recognizes @material_number it stores the provided user input under a context variable $materialnumber and then responds "Oh, the material number is $materialnumber".

The thing is that when the input of the user belongs to the value either num2 or num3, the bot only stores the first 6 digits provided. For instance when the input is 123.123.123.123 or 123.123.123, the bot only stores first six digits (seperated with a dot from the middle) and prompts back "Oh, the material number is 123.123".

By using JSON editor, it should be possible to overcome this confusion.

1
Will there be more patterns (num4, num5, ...)? Do you look for a specific solution or something more general?data_henrik
For this specific entity, there will not be more patterns, sir !Ömer Kadıoğlu

1 Answers

2
votes

Similar to the solution suggested in this answer, you can nest ternary operators:

{
  "context": {
    "number1": "<? @number1:mat3 ? entities.number1[2].literal : @number1:mat2 ? entities.number1[1].literal : entities.number1[0].literal ?>"
  }
}