-
Notifications
You must be signed in to change notification settings - Fork 39
CatchAll Activator
CatchAllActivator can be used in JAICF project to handle any user's query request that wasn't handled by any other activator.
Usually this activator is used to handle fallback queries when user says something that is not expected at the current state of the dialogue.
Another user-case is to handle all raw user's input for some purposes (for example, if user dictates a text of reminder note).
All you need to use this activator in your JAICF project is to add catchAll
activators to the scenarios and then append CatchAllActivator
to the BotEngine
's array of activators.
state("fallback", noContext = true) {
activators {
catchAll()
}
action {
reactions.say("Sorry, I didn't get it... Could you repeat please?")
}
}
val helloWorldBot = BotEngine(
model = HelloWorldScenario.model,
activators = arrayOf(
...,
CatchAllActivator
)
)
Please note that CatchAllActivator
should be places the last in the array of activators once it catches every query request from the user.
Once a CatchAllActivator
activates some state, a CatchAllActivatorContext instance becomes available through an activator.catchAll
variable in the action block of this state.
It doesn't contain any data but can be used to determine if the state was activated by CatchAllActivator
.
Note that is you need to obtain a raw user's request text, you can use request.input
in your action block.
state("state1") {
activators {
intent("SomeIntent")
catchAll()
}
action {
activator.catchAll?.run {
reactions.say("This state was activated by catchAll activator because you've said ${request.input}.")
}
}
}
Learn more about request here.