Event Activator - just-ai/jaicf-kotlin GitHub Wiki
EventActivator can be used in JAICF project to handle some events generated by channels that are not a result of user's speech or text request.
Some channels generate such events in cases like launching a voice skill (Alexa's "LAUNCH" event), audio player events ("PLAY", "STOP" and etc.) and some others.
How to use
All you need to use event activator in your JAICF project is to add event
activators to the scenarios and then append BaseEventActivator
to the BotEngine
's array of activators.
event actovator
state("next") {
activators {
event(AlexaEvent.NEXT)
intent(AlexaIntent.NEXT)
}
action {
...
}
}
state("pause") {
activators {
event(AlexaEvent.PAUSE)
intent(AlexaIntent.PAUSE)
}
action {
...
}
}
Learn more about activators here.
EventActivator configuration
Event activator is built-in into every BotEngine
by default and doesn't require any additional configuration.
Some channels provide its own implementation of EventActivator.
Thus if you create an Alexa-only agent, you may omit BaseEventActivator
from the activators
array:
val helloWorldBot = BotEngine(
model = HelloWorldScenario.model,
activators = arrayOf(
AlexaActivator
)
)
Event name
Once a EventActivator
activates some state, a EventActivatorContext instance becomes available through an activator.evebt
variable in the action block of this state.
This object contains the name of the event that activated this state.