$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
CatchAllstate will be triggered. The/CatchAllclass will be displayed in the dialog history. - If you send
ghbdtnto the bot, theCatchAllstate will be triggered. You will also be redirected to theHellostate. The/Helloclass 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 theCatchAllstate. Then you will be redirected to theHellostate. The/CatchAllclass will be displayed in the dialog history.