How to capture a user's full name from their text input using watson's assistant dialog?

723 Views Asked by At

I(as a newbie) am setting up a messenger chatbot using IBM's watson. I want to get a user to type in their information and I save it as a variable.

For example:

chatbot:  What is your name?
User: I am Angella Naigaga
chatbot saves "Angella Naigaga"
Chatbot: Thank you Angella
1

There are 1 best solutions below

0
Michal Bida On

Watson Assistant supports regular expressions - both in entities and also directly accessible from input.text field.

For example this expression will set up name variable to capture names consisting of two words with optional "I am " before that.

"context" : {
    "name" : "<?input.text.extract('(I am )?(\\w+ \\w+)',2)?>"
}

More documentation about regexp and also a webpage where one can try how the regexp matches is here:

https://regex101.com/

Note that this is quite technical and as data_henrik suggests some slot tutorials might be a better bet.