How to detect if user input have one word only in Watson Assistant?

571 Views Asked by At

I am using the IBM Watson Conversation Assistant Chatbot. I am having troubles finding in the documentation how to detect if the user input consists of a single word. It's fine for simplicity and for my goal to use the presence of spaces as surrogate (no spaces means only word).

I tried using SpEL. I tried also to intercept the following as Node entry:

request.input.text:" "

with scarce results.

What should I write into the "If assistant recognizes:" field?

2

There are 2 best solutions below

0
Daniele D. On BEST ANSWER

Here how I solved, hopefully will save a lot of time to someone else.

Inside the node, under "If assistant recognizes:"

!input.text.contains(' ')

Then respond with:

You wrote  "<? input.text ?>". Please write full sentences.
1
Mahesh Patil On

You can use the JavaScript DOM element to read the inner text and manipulate it.