Creating skills for Alice

As an example, we'll create a skill called Parrot, which repeats everything a user writes or says. We implement our example in two programming languages: Python and Node.js.

Note

Functions can't be used for Smart Home skills yet.

To add skills based on a function to Alice:

  1. Prepare the skill code.
  2. Create a function.
  3. Create a version of the function.
  4. Make the function public.
  5. Add the function link to Alice's skill.
  6. Test the skill.

More about developing Alice's skills.

Prepare the code for Alice's skill

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.

  1. Download a sample file from GitHub: parrot.py.
  2. Create a ZIP archive named parrot-py.zip and add the parrot.py file.
  1. Download a sample file from GitHub: index.js.
  2. Create a ZIP archive named parrot-js.zip and add the index.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 you create a version.

  1. In the management console, select the folder where you want to create your function.

  2. Click Create resource.

  3. Choose Function.

  4. Enter a function name.

    The name must be unique within the folder. The name may contain lowercase Latin letters, numbers, and hyphens. The first character must be a letter. The last character can't be a hyphen. The maximum length of the name is 63 characters.

  5. Click Create.

Create a version of the function

Choose the programming language and create a version of the function.

  1. In the management console, open Cloud Functions in the folder where you want to create the function version.
  2. Select the function to create the version for.
  3. Under Latest version, click Create in editor.
  4. Set the version parameters:
    • Runtime environment: python37.
    • Timeout, seconds: 2.
    • RAM: 128 MB.
    • Service account: Not selected.
  5. Prepare the function code:
    • Method: ZIP archive.
    • File: parrot-py.zip.
    • Entry point: parrot.handler.
  6. Click Create version.
  1. In the management console, open Cloud Functions in the folder where you want to create the function version.
  2. Select the function to create the version for.
  3. Under Latest version, click Create in editor.
  4. Set the version parameters:
    • Runtime environment: nodejs12.
    • Timeout, seconds: 2.
    • RAM: 128 MB.
    • Service account: Not selected.
  5. Prepare the function code:
    • Method: ZIP archive.
    • File: parrot-js.zip.
    • Entry point: index.handler.
  6. Click Create version.
  1. Go to Alice's skill page in your dashboard.
  2. Open the Settings tab.
  3. Under Backend, select Function in Yandex.Cloud.
  4. Select the desired function from the drop-down list.
  5. Click Save at the bottom of the page to save changes.

Test the skill

  1. Open the Testing tab on the skill page in your dashboard.
  2. 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..
  3. Send a message and make sure the response is the same.