Creating skills for Alice
As an example, we will create a skill called Parrot
, which repeats everything a user writes or says. The example is based on two programming languages: Python and Node.js.
To add an Alice skill based on a function:
- Prepare your cloud.
- Prepare the skill code.
- Create a function.
- Create a function version.
- Add the function link to Alice's skill.
- Test the skill.
If you no longer need the resources you created, delete them.
You can find more information about developing skills for Alice here
Getting started
Sign up for Yandex Cloud and create a billing account:
- Go to the management console
and log in to Yandex Cloud or create an account if you do not have one yet. - On the Yandex Cloud Billing
page, make sure you have a billing account linked and it has theACTIVE
orTRIAL_ACTIVE
status. If you do not have a billing account, create one.
If you have an active billing account, you can go to the cloud page
Learn more about clouds and folders.
Prepare the code for Alice's skill
To create a version of a function, you can use one of the code upload formats. As an example, we will upload the code as a ZIP archive.
- Download a sample file from GitHub: parrot.py
. - Create a ZIP archive named
parrot-py.zip
and add theparrot.py
file.
- Download a sample file from GitHub: index.js
. - Create a ZIP archive named
parrot-js.zip
and add theindex.js
file.
Create a function
Once created, the function will only contain information about itself, like its name, description, and unique ID. The skill's code will be added to the function when creating a version.
-
In the management console
, select the folder to create your function in. -
Click Create resource.
-
Select Function.
-
Enter a function name. The naming requirements are as follows:
- The name must be from 3 to 63 characters long.
- It may contain lowercase Latin letters, numbers, and hyphens.
- The first character must be a letter and the last character cannot be a hyphen.
-
Click Create.
Create a function version
Select the programming language and create a version of the function.
- In the management console
, open Cloud Functions in the folder where you want to create the function version. - Select the function to create the version for.
- Under Last version, click Сreate in editor.
- Set the version parameters:
- Runtime environment:
python37
- Timeout, sec:
2
- Memory:
128 MB
- Service account:
Not selected
- Runtime environment:
- Prepare the function code:
- Method:
ZIP archive
- File:
parrot-py.zip
- Entry point:
parrot.handler
- Method:
- Click Save changes.
- In the management console
, open Cloud Functions in the folder where you want to create the function version. - Select the function to create the version for.
- Under Latest version, click Create in editor.
- Set the version parameters:
- Runtime environment:
nodejs12
- Timeout, sec:
2
- Memory:
128 MB
- Service account:
Not selected
- Runtime environment:
- Prepare the function code:
- Method:
ZIP archive
- File:
parrot-js.zip
- Entry point:
index.handler
- Method:
- Click Save changes.
Add the function link to Alice's skill
-
Go to the Alice skill page in your dashboard
. -
Click Create dialog. In the window that opens, select Alice skill.
-
On the Settings tab, in the Backend field, select Function in Yandex Cloud. Select the function you need from the dropdown list.
Warning
The list shows the functions that you are allowed to view. To attach a function to a skill, you need permission to launch the function. This permission is part of the roles functions.functionInvoker, editor and higher.
-
Click Save at the bottom of the page to save changes.
Test the skill
- Open the Testing tab on the skill page in your dashboard
. - If everything is set up correctly, the Chat section will display a message inviting you to start a conversation:
Hello! I'll repeat anything you say to me.
. - Send a message and make sure the response is the same.
How to delete the resources you created
To stop the skill, delete the function.