1

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.

data_henrik
  • 16,724
  • 2
  • 28
  • 49

1 Answers1

2

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 ?>"
  }
}
data_henrik
  • 16,724
  • 2
  • 28
  • 49
  • You are a genius ! I appreciate all your effort, sir. I also have asked a new question with the title "IBM Watson Chatbot: Handling Multiple Entities". I would be even more grateful if you can help me out with that one when you have time. – Ömer Kadıoğlu Sep 20 '18 at 13:18