Step 19: Let Alan start the dialog

When users open the app, we want Alan AI to greet them and prompt what they can do with voice. To do this, we will use Alan AI’s onUserEvent predefined callback.

To the dialog script, add the following code:

Dialog script
onUserEvent((p, e) => {
    if (e.event == 'micPermissionPrompt') {
        p.play('Hi, this is Alan, your voice assistant!');
        p.play('To order food with voice, click Allow microphone and say: I want two burritos or I will take a pepperoni, please');
    }
});

Web page source | Dialog script

Now, when the user clicks the Alan AI button and the microphone permission prompt is displayed, the AI assistant will play a prompt on how the user can order food with voice.

Refresh the page and click the Alan AI button to test this scenario.