2

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
Simon O'Doherty
  • 9,259
  • 3
  • 26
  • 54
Anjayluh
  • 1,647
  • 1
  • 13
  • 22
  • Are you using Slots? – data_henrik May 13 '19 at 08:28
  • I'm not familiar with slots. But so far I have managed to use input.text though I can't say I really know what I am doing. – Anjayluh May 13 '19 at 08:52
  • https://cloud.ibm.com/docs/services/assistant?topic=assistant-dialog-slots I recommend following through one of the tutorials. Obtaining names, locations, etc. is a very common tasks and there are samples in the documentation. Else, add a specific code problem to your question. – data_henrik May 13 '19 at 09:35

1 Answers1

0

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.

Michal Bida
  • 1,316
  • 9
  • 24