The Slang Assistant handles most of the heavy lifting of interacting with the end-users and notifies the app when there is some action to be performed by the app. But in some cases, apps may want to be notified of low-level events that the Assistant is aware of. For example, whenever a user clicks on the trigger (the microphone button) or when the user cancels the Slang surface.
Access to low-level Assistant events is available through the Assistant's Lifecycle Events API.
The app can register with the Assistant to be notified of all interesting life-cycle events via the
As part of the Lifecycle Events API, an observer will be notified of the following events:
Called as soon as the Assistant has initialized successfully and is ready to serve the app
Called when the Assistant failed to initialize successfully. The reason is passed as a parameter to this callback
Called whenever the Assistant has been launched (this can be either as a result of the user clicking on the trigger or the app invoking the Assistant via the
Called whenever the Assistant has been dismissed. A boolean parameter
isCanceled is passed to indicate whether this happened because the user canceled the session or if the Assistant was done with its job
Called whenever the user changes the locale of the Assistant
Called whenever the Assistant is not able to understand what the user spoke. The utterance that the user spoke is passed as a parameter.