In this example, we will create a voice script with simple voice commands, we will learn how to test voice script in the Alan Studio and how to add the Alan Button to the HTML webpage.
Creating a voice script in Alan Studio
Go to the Alan Studio and create a project there:
Create a new voice script in the project:
In the "Add script" popup you can create an empty script or you can choose a script from the list of predefined scripts. These scripts show different examples of voice scripts for a variety of scenarios of use.
- Add the following intents into the script code area and save your changes:
intent(`Hi`, reply(`Hello`)); intent(`Who are you?`, reply(`I'm Alan, your virtual voice assistant`));
An intent is a voice command the user says to receive a voice response or specific functionality from an application.
- Now, when changes were saved, you can test your voice script in the "Debugging Chat" area in the right part of the screen. You can type your intents there and after pressing the "Enter" key, you will be able to see Alan's responses which you defined in the script on step #3. Also, you can press the Alan Button in the right bottom corner and test your script with voice. Just say "Hi" or "Who are you?" and you will be able to listen to Alan's response.
Adding the Alan button to the client page
- Go to the "Embed Code" page to see examples of integrations of the Alan Button for different platforms:
For simplicity purposes, we will add the Alan Button to the HTML page, but on the "Embed Code" page you can also find instructions on how to add the Alan Button for iOS and Android platforms.
Click the "Copy all" button to copy the full HTML code and save it in a new file "testAlanButton.html".
When you open the "testAlanButton.html" file in the browser, you will see the empty page with the Alan Button in the right bottom corner. If you activate the Alan button, you will be able to ask intents which you defined in your voice script ("Hi" or "Who are you?") and get Alan's responses.
The page will work in the latest versions of Chrome, Firefox, Microsoft Edge. You will need to give microphone access after pressing the Alan button. Some browsers may block microphone access on unsecured pages or allow it only during the current session.
Congratulations! You have created your first Alan application and learned how to debug the voice scripts in Alan Studio! You can find more examples in the "Tutorials" section of this Documentation. Check out the Food Delivery Complete Application Tutorial to see the full example of creating the Food Delivery app with the power of voice.