-
Notifications
You must be signed in to change notification settings - Fork 39
Event Activator
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.
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.
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.
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
)
)
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.