Step 16: 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 agent!');
        p.play('To order food with voice, click Allow microphone and say: I want two burritos or I will take a pepperoni, please');
    }
});

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

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