Step 4: Add a voice command

When we created the project in Alan AI Studio, Alan AI automatically added a dialog script with a simple voice command to it. We will use it as an example to add a new command, or intent, to the dialog script.

To the dialog script, add the following command and save the script:

Dialog script
intent('I want a pepperoni', p => {
    p.play('Adding pepperoni for you');
});

Note

p in the command references an internal object that we can use to call Alan AI’s native methods and access its predefined objects. Here, it is used to call the play() method.

Check how the new command works in the Debugging Chat in the right pane of Alan AI Studio or directly in the web page. Click the Alan AI button and say: I want a pepperoni. The AI agent will reply: Adding pepperoni for you.