Skip to main content

$nlp.setClass

You can use this function to assign any nlp class to a pair of client/bot phrases, and this class will be displayed in the Class field in the dialog history.

The function accepts the nlp class as a string argument. For example:

$nlp.setClass ("/set/new/class")

How to use

Here is an example:

theme: /

state: CatchAll
q!: *
script:
if ($parseTree.text.equals("ghbdtn")) {
$nlp.setClass("/Hello");
$reactions.transition("/Hello");
} else {
$reactions.answer("I cannot understand you");
}


state: Hello
q!: Hi
a: Good afternoon!

Here:

  • If you send any phrase to the bot, the CatchAll state will be triggered. The /CatchAll class will be displayed in the dialog history.
  • If you send ghbdtn to the bot, the CatchAll state will be triggered. You will also be redirected to the Hello state. The /Hello class will be displayed in the dialog history.
  • However, if you remove the $nlp.setClass("/Hello"); line from the script, the query will be handled by the CatchAll state. Then you will be redirected to the Hello state. The /CatchAll class will be displayed in the dialog history.