0
votes

I'm pretty new to Watson Conversation and Watson in generel, and I've come across a situation that I would like to handle in the Watson Conversation app, but I can't figure out.

Basically I want to add an "advanced" condition to a response so it will be possible to do e.g.:

Condition: if @sys-number==Integer

Response: @sys-number is an integer.

Condition if @sys-number==Double

Response: @sys-number is a double.

Currently I'm stuck, since I can get the @sys-number class by doing @sys-number.numeric_value.class, which evaluates to e.g. "class java.lang.Integer", but I cannot do the comparison in the condition field.

I've tried to do several different things, where the most obvious would be

if (@sys-number instanceof java.lang.Integer)

I know that this can be handled on the application side, but would like a solution Conversation side, if possible.

2

2 Answers

1
votes

By essence the '@sys-number' entity is a string, because it belongs to the user's input. So if you want to test wether the user's input recognized @sys-number entity can be converted onto integer or a float you must try :

IF @sys-number AND input.text.find('\d+') 

IF @sys-number AND input.text.find('\d+[,\.]\d+')

If and only if none of the condition is triggered, the @sys-number comes from Alphabetic input

0
votes

Use a regular expressions for example the following will look for an integer.

/^[0-9]*$/