Step 19: Let Alan start the dialog

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

To the voice script, add the following code:

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

Web page source | Voice script

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

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