-
Notifications
You must be signed in to change notification settings - Fork 39
reactions
Reactions is a main interface for building the response that should be sent back to the user. It also contains functions for dialogue state managing.
Each channel in JAICF creates it's own channel-related Reactions implementation and provides it through the ActionContext to the action block of the scenario. Once the state is activated, JAICF executes it's action block in context of this object, thus reactions interface becomes available for response building and dialogue state managing. Here is a simple example:
state("fallback", noContext = true) {
activators {
catchAll()
}
action {
reactions.say("I have nothing to say yet...")
reactions.actions?.run {
say("Bye bye!")
endConversation()
}
}
}
Here you can see how reactions
is used.
Once a "fallback" state is activated, JAICF executes it's action block.
Reactions instance contains say
method to send a raw text in the response to the user.
Channel that received a request and created this
Reactions
is responsive for this function invocation handling.
Each Reactions
instance contains functions that help to build a response(s).
say
method just appends a raw text reply to the response.
There is also sayRandom
variation of this method that picks a random text to append to response.
image
method appends an image URL to the response.
Please note that not every channel supports this type of reply.
buttons
method appends buttons array to the response.
Please note that not every channel supports this type of reply.
You can also notice how channel-related reactions can be used.
In the example above there is a null-safe invocation of reactions.actions?
that works only in case the request was received by Google Actions channel. In this case a channel-related reactions become available - like Actions-related endConversation
function that finishes the Actions execution on a Google Assistant's side.