Powered by Algolia

Voice scripts

To let users interact with your application with their voice, you must create a voice script in the Alan Studio. A voice script is a scenario by which the dialog with the user is carried out. It contains a set of commands that the user can execute and actions that must be taken in response to these commands.

Voice scripts are written in JavaScript. You can use Alan objects and entities and standard JavaScript means to write scripts. For details, see Server API.

In Alan, you can create custom scripts or use predefined scripts. Alan comes with a library of script templates that can give you a good example of how a voice script can be organized. You can add and remove predefined scripts from the project at any moment.

An Alan project can contain one or multiple voice scripts. Multiple scripts can be helpful, for example, if you want to split the project logic and separate configuration and data structures from utility functions. This will make your project more transparent and easier to support.

In projects with multiple scripts, scripts are loaded in the order they are set up, starting from the upper one. You can use the Alan built-in functionality to share data and make it accessible between scripts. For details, see Multiple scripts in the project.

To work with scripts in the Alan Studio, you can do the following:

Managing scripts

To add a voice script to the Alan project:

  1. In the Alan Studio, open the project to which you want to add a voice script.
  2. In the left pane, click Add Script.
  3. Do either of the following:

    • To add a custom script, in the New script name field, enter the script name and click Add New Script to the right.
    • To add a predefined script, in the Predefined script templates list, select one or multiple scripts and click Add Predefined Scripts at the bottom of the window.
You can rename a script or delete it from the project when necessary.
  • To rename a script, hover over the script name in the left pane and click the edit icon.
  • To delete a script, hover over the script name in the left pane and click the delete icon.\

Downloading scripts

You can download a copy of your scripts from the Alan project, for example, if you want to save some script version locally.

To download scripts from the Alan project:

  1. In the Alan Studio, open the project from which you want to download a script copy.
  2. In the left pane, select one or more scripts you want to download.
  3. At the top of the left pane, click the Download scripts icon. Alan will save a ZIP archive to the default downloads location on your computer.

Importing scripts

If you have an external file with a voice script, you can import it to work with it in the Alan Studio. For example, you may want to import voice scripts that you downloaded from the Alan Studio previously and stored locally on your computer.

To import voice scripts to the Alan Studio:

  1. In the Alan Studio, open the code editor.
  2. Drag one or more voice script files and drop them onto the drop zone at the bottom left of the Alan Studio. You can also click the message in the drop zone and select one or more files to be imported.

In case an imported script has the same name as a script already added to the project, you can choose to replace the existing script or add the imported script as a copy.

Customizing the code editor

Scripts are written in the Alan Studio code editor. The editor is designed specifically for work with voice scripts: it lets you comfortably write voice commands and highlights voice interface-specific errors in an intelligent way.

You can customize the editor to meet your personal preferences. Alan offers the following options:

  • Group the script by voice commands. To easily navigate in the voice script, at the top of the editor, click Show only intents. The voice script will be collapsed and grouped by commands you have in the script.

    In the Show only intents mode, Alan highlights active and dependent commands with different colors. For example, intents are presented as colored blocks while follows dependent on the context are grayed out. This helps you understand how your voice script is organized.

    To get to a specific command, to the left of the command, click the active or inactive icon.

    To get back to the regular mode, at the top of the editor, click Show all code.

  • Select the theme and font size. By default, the script editor uses the standard Alan theme and medium font size. To customize the code editor appearance, at the top of the editor, click Code Style and select the necessary theme and font size.
  • Make more room for the editor. To make the script editor window wider, use the arrow icons at the top left and top right of the editor window.