Run JS code on every intent submitted

Hello,
Some of our bot owners would like to be able to display a message if the user intent is too short or too long. My initial output on this was to run JS code to detect phrase length and display a message accordingly. However they want to run this on every inputs, even successfull queries (or false positives). Now, I now we can run this on every intent not found or ambiguous intent. But is there a way to run this on every input ?

Thank you in advance.

Clément,

I’m trying to understand the use case.

Why would you want to run some length test on every utterance and display a message? If you are in a flow and at an entity/confirmation prompt then a perfectly response could be one word, so displaying an extra message seems like it would be getting in the way of the conversation. Can you describe more of what you would like to achieve?

I can understand the case for intent not found or ambiguity to ask the user to say more, or less.

I agree with you, in my opinion it should be only on intent not found or ambiguity. Ideally for my bot owners, it should be run on every KG usage, so not in the flows. My question is really about feasability in fact.

Well a KG response can be generated by script, so you could ensure that every KG response called some common function that tested the utterance, which is in the context object.

I remain unconvinced of the utility though - how is the user supposed to react to being told their input is too short/long even when they have an answer?

Yeah that’s the option I had in mind, but that would mean moving every answer to “advanced mode” and have it call the js before showing the option.

For the business point of view, it’s about spreading the good practice.

The other option is to use botkit, which acts as a filter on all incoming and outgoing messages.