Creating a skill for Alice
As an example, we will create a skill called Parrot
, which repeats everything a user writes or says. The example is available in two programming languages: Python and Node.js.
To add a skill for Alice based on a function:
- Get your cloud ready.
- Prepare the skill code.
- Create a function and 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.
More on developing a skill for Alice
Getting started
Sign up for Yandex Cloud and create a billing account:
- Navigate to the management console
and log in to Yandex Cloud or create a new account. - On the Yandex Cloud Billing
page, make sure you have a billing account linked and it has theACTIVEorTRIAL_ACTIVEstatus. If you do not have a billing account, create one and link a cloud to it.
If you have an active billing account, you can create or select a folder for your infrastructure on the cloud page
Learn more about clouds and folders here.
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.zipwith theparrot.pyfile.
- Download a sample file from GitHub: index.js
. - Create a ZIP archive named
parrot-js.zipwith theindex.jsfile.
Create a function and a function version
Once created, the function will contain only information about itself: name, description, unique ID, etc. The actual skill code will be added to the function version.
-
In the management console
, select the folder to create the function in. -
Click
Create resource and select Function. -
Enter a function name. Follow these naming requirements:
- Length: between 3 and 63 characters.
- It can only contain lowercase Latin letters, numbers, and hyphens.
- It must start with a letter and cannot end with a hyphen.
-
Click Create.
-
Create a function version:
PythonNode.js-
From the list of programming languages, select
Python 3.12. -
Disable Add files with code examples and click Continue.
-
Prepare the function code:
- In the Code source field, select
ZIP archiveand attach theparrot-py.ziparchive you created earlier. - In the Entry point field, specify
parrot.handler.
- In the Code source field, select
-
Set the version parameters:
- Timeout:
2. - Memory:
128 MB. - Leave the rest of the parameters at their defaults.
- Timeout:
-
Click Save changes.
-
From the list of programming languages, select
Node.js 18. -
Disable Add files with code examples and click Continue.
-
Prepare the function code:
- In the Code source field, select
ZIP archiveand attach theparrot-js.ziparchive you created earlier. - In the Entry point field, specify
index.handler.
- In the Code source field, select
-
Set the version parameters:
- Timeout:
2. - Memory:
128 MB. - Leave the rest of the parameters at their defaults.
- Timeout:
-
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 Skill.
-
On the Settings tab:
- In the Skill name field, specify a unique name for the skill you are creating.
- In the Backend field, select Function in Yandex Cloud. Select the function you created earlier from the drop-down 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 included in the functions.functionInvoker and editor roles or higher.
- At the bottom of the page, click Save.
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.