2

I'm building a chat-bot application based on IBM Watson. I need to save the user input into a variable.

I searched the web and I only found tutorials where the input must be of entity sys-(number, day, time, location, person).

In my dialog I ask the user about his identifier. This identifier should be an alphanumerical string.

How can I do so?

Dr. MAF
  • 1,853
  • 1
  • 27
  • 45

2 Answers2

3

User input can be accessed as a String by this expression: <?input.text?>

Michal Bida
  • 1,316
  • 9
  • 24
2

Take a look at this IBM Cloud solution tutorial that creates a chatbot. It uses identifiers for emails, URIs and conferences.

I see two options for your case:

  1. Define an entity type "identifier" and use a pattern in its definition. The pattern would be the alphanumerical regular expression. For a slot, assign the entity of "identifier" as necessary input.
  2. Use the value of the input variable. Thereafter, extract the identifier by applying string methods.

To access the actual value in a detected entity, use the value property. See the Watson Assistant docs on entity properties for the full syntax and examples.

data_henrik
  • 16,724
  • 2
  • 28
  • 49
  • OK. I created an entity with value "identifier" and pattern "^Id[A-Za-z0-9]+$". If the input is IdAB123, I get "identifier" as the result instead of the real input. How to solve this? – Dr. MAF Sep 23 '19 at 15:50
  • see the last paragraph of my answer which I added – data_henrik Sep 23 '19 at 16:10
  • I use a slot and I tried @identifier.value already in CHECK FOR. And $myVariable in SAVE IT AS. I still get "identifier" saved to $myVariable . I build my dialog using wizard. – Dr. MAF Sep 23 '19 at 16:46