Want to Check If the Chat input is a number or a word

I am using a chat trigger after that I have added a edit Node which is splitting the message in different items, Now I want to check if one particular item is a string or a number. Please suggest some solution?

Hey @Digital_Grooming hope all is good. Welcome.

How about this

In chat type
word 42

it will return that 42 is a number.

The check happens in the If node, where we check if “42”.isNumeric().

Word of caution:
42 is a string, but it is numeric, meaning that it’s a string representation of number 42.

1 Like

@Jabbson Thanks Man, It worked. I just started learning n8n from a week, and with the help of members like you I am sure I am gonna learn a lot.

A small doubt.. in the first edit node why can’t we just use {{ $json.chatInput.split(’ ') }}. why we have to use two input fields as {{ $json.chatInput.split(’ ') [0] }} or {{ $json.chatInput.split(’ ')[1]}}

Oh we totally can just use split, then we will end up with an array, not a problem.

In your initial message you just said that you

have added a edit Node which is splitting the message in different items

and I assumed that you’ve created multiple items from the input string, so I tried to reproduce your setup as close as possible.

If you would rather have an array:

No rules here, do as you wish :slight_smile: