title: "Creating skills for Alice" description: "An example of creating a skill for Alice in two programming languages: Python and Node.js As an example, we'll create an Alice's skill called <q>Parrot</q> that will repeat everything the user writes or says." keywords:
- creating skills for Alice
- Alice skills
- example of creating a skill for Alice
Creating skills for Alice
As an example, we will create a skill called <q>Parrot</q>, 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 {#before-you-begin}
{% include before-you-begin %}
Prepare the code for Alice's skill {#prepare-code}
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.
{% list tabs %}
-
Python
- Download a sample file from GitHub: parrot.py.
- Create a ZIP archive named
parrot-py.zipand add theparrot.pyfile.
-
Node.js
- Download a sample file from GitHub: index.js.
- Create a ZIP archive named
parrot-js.zipand add theindex.jsfile.
{% endlist %}
Create a function {#create-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]({{ link-console-main }}), select the folder to create your function in.
-
Click Create resource.
-
Select Function.
-
Enter a function name.
{% include name-format %}
-
Click Create.
Create a function version {#create-version}
Select the programming language and create a version of the function.
{% list tabs %}
-
Python
- In the [management console]({{ link-console-main }}), open {{ sf-name }} 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:
python37. - Timeout, seconds: 2.
- RAM: 128 MB.
- Service account: None selected.
- Runtime environment:
- Prepare the function code:
- Method: ZIP archive.
- File:
parrot-py.zip. - Entry point:
parrot.handler.
- Click Create version.
-
Node.js
- In the [management console]({{ link-console-main }}), open {{ sf-name }} 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, seconds: 2.
- RAM: 128 MB.
- Service account: None selected.
- Runtime environment:
- Prepare the function code:
- Method: ZIP archive.
- File:
parrot-js.zip. - Entry point:
index.handler.
- Click Create version.
{% endlist %}
Add the function link to Alice's skill {#add-link}
-
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.
{% note warning %}
The list shows the functions that you're allowed to view. To attach a function to a skill, you need permission to launch the function. This permission is part of the roles {{ roles-functions-ivoker }}, {{ roles-editor }} and higher.
{% endnote %}
-
Click Save at the bottom of the page to save changes.
Test the skill {#test}
- 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 created resources {#clear-out}
To stop the skill, delete the function.