Step 4: Add a voice command

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

To the voice script, add the following command and save the 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’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 Studio or directly in the web page. Click the Alan button and say: I want a pepperoni. Alan will reply: Adding pepperoni for you.