Documentation

Powered by Algolia

Voice assistant lifecycle

To create a reliable voice assistant, you must understand in which state a dialog with the user can be and know how and when the dialog transitions between the states.

Every project you create with Alan goes through the following workflow:

  1. Project is created: The project lifecycle begins when you create and save scripts for your voice assistant in the Alan Studio. At this step, Alan loads the scripts in the Alan Cloud and builds the project model for the voice assistant.

    Alan reloads scripts and rebuilds the project model every time you update and save scripts in the Alan Studio.

  2. User is connected: When a new user opens an app with the Alan button and starts a conversation, Alan connects to the project in the Alan Cloud, creates a new dialog for this user and assigns a unique ID to this dialog. For every user interacting with Alan, a separate dialog is created. All the communication with Alan is performed within this dialog, even if the user stops interaction for a while by clicking or tapping the Alan button.
  3. User is disconnected: When the user stops the voice session with Alan, he or she gets disconnected, and Alan closes the dialog created for the user. The dialog can also be closed in the following cases:

    • The voice session with the user is inactive for a 30-minute period.
    • The voice scripts for the project are reloaded.

Lifecycle predefined callbacks

As the dialog transitions from state to state, you may need to adjust the voice assistant behavior. To let you do it, Alan offers a set of predefined callbacks. You can use these callbacks to perform necessary tasks and handle significant events in your voice script.

Here is a list of callbacks that can be used in Alan:

  • onCreateProject: This callback is to be called when the project is created and the project model is built. You can perform any initialization activities that may be required for your voice assistant.
  • onCreateUser: This callback is to be called when a new user connects to Alan and starts the dialog session. Here, for example, you can set user-specific data.
  • onCleanupUser: This callback is to be called when the user disconnects from Alan or the dialog is closed. Here you can perform any cleanup activities or save the user data.
  • onVisualState: This callback is to be called when a visual state is set in the client app.
  • onEnter: This callback is to be called when a context added to the script is activated.