问题
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?
回答1:
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:
- 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.
- 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.
回答2:
User input can be accessed as a String by this expression: <?input.text?>
来源:https://stackoverflow.com/questions/58049981/save-user-input-string-in-watson-assistant