0
votes

I need the user to input his flight number in order to fetch its details for him.
Is there any way to detect and store the flight number (3-4 digits + words) that he entered?
I know that I can create an entity in order to store some parts of the user inputs, but it seems like I have to hard-code values which I want to retrieve, which is not practical.
So, is there any option to make watson automatically detect a part of user input (not limited to numbers).

1

1 Answers

1
votes

In your condition section you can put in the following.

input.text.matches('.*?[0-9]{3,4}.*?')

For your output area, go to advanced mode and do the following.

{
    "output": {
        "text": "You typed a 3-4 digit number. I stored it in Context variable 'found'"
    },
    "context": {
        "found": "<? input.text ?>"
    }
}

You can then query the context variable found in your code to do more complex actions on it.


Conversation has been updated since this answer. You can now use input.text.extract() instead of just input.text.

Like so:

"found": "<? input.text.extract('.*?([0-9]{3,4}).*?',1) ?>"