cancel
Showing results for 
Search instead for 
Did you mean: 

CAI check current message or memory field is numeric

alicja_z
Explorer
0 Kudos

Hello,

I am working on a bot that should create a purchase requisition.

I have several entities that are numeric. For example, plant is a four digit number or G/L account - a six digit number. When the user is asked for quantity, he enters a number. Normally it should be recognized as #number and can be processed further.

Sometimes this number is recognized as a plant or account.

In this case I wanted to save the current message in fallback-skill as quantity. I just need to check that the entry is numeric.

How can I check if the current message or a memory field is numeric?

Best regards and thanks in advance!

Alicja

Accepted Solutions (1)

Accepted Solutions (1)

Dan_Wroblewski
Developer Advocate
Developer Advocate

I would rethink the flow and try to get better detection, or ask for the quantity explicitly.But one way to detect a number is to add the number to itself and then test if you have a string or not:

NUMBER: {{isString (add "1" "1")}}
NOT NUMBER {{isString (add "A" "1")}}

The first returns false and the second returns true.

Unfortunately, I don't see any explicit function for testing or converting strings to numbers.

alicja_z
Explorer
0 Kudos

Thank you! It was very valuable advice that we have also implemented.

Answers (0)