Creating skills for Alice
As an example, we'll create a skill called <q>Parrot</q>, which repeats everything a user writes or says. We implement our example in two programming languages: Python and Node.js.
To add skills based on a function to Alice:
- Prepare the skill code.
- Create a function.
- Create a version of the function.
- Add the function link to Alice's skill.
- Test the skill.
More about developing Alice's skills.
Prepare the code for Alice's skill {#prepare-code}
To create versions of functions, you can use one of the code upload formats. As an example, we'll upload the code in a ZIP archive.
{% list tabs %}
-
Python
- Download a sample file from GitHub: parrot.py.
- Create a ZIP archive named
parrot-py.zipwith 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 you create a version.
-
In [management console]({{ link-console-main }}), select the folder where you want to create your function.
-
Click Create resource.
-
Choose Function.
-
Enter a function name.
{% include name-format %}
-
Click Create.
Create the version of the function {#create-version}
Choose 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: Not 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: Not 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 Alice's skill page in your dashboard.
-
Open the Settings tab.
-
Under Backend, select Function in Yandex.Cloud.
-
Select the desired function from the drop-down 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-functions-ivoker }}, {{ roles-editor}}, and higher roles.
{% 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.