onEvent handler
Responsible for handling events received from Alan.
While Alan interacts with the user and interpretes the user’s input, it emits a series of events. For each event, Alan generates JSON output with the event description. You can intercept the event information and use it in your app logic if needed.
You can use the following Alan events:
recognized event
The event is emitted during and upon the user’s input recognition. The event description contains the interpreted phrase and the recognition state in the final
field:
- If the user’s input is being recognized, the
final
field value isfalse
. - If the user’s input has been recognized, the
final
field value istrue
.
// The user’s input is being recognized
{text: hello, final: false}
// The user’s input has been recognized
{text: hello, final: true}
parsed event
The event is emitted after the user’s input has been parsed and interpreted.The event description contains the interpreted user’s phrase.
{text: hello}
text event
This event is emitted when Alan plays the reply to the user. The event description contains Alan’s phrase.
{text: I'm here}