How to Update Your Alexa Skills for Italy

Sebastien Stormacq Jun 18, 2018
Tips & Tools

Today, we announced that Amazon Alexa and Alexa-enabled devices are coming to Italy later this year. Starting today, you can use the Alexa Skills Kit (ASK) to build skills for customers in Italy using the new Italian language model.

If you are new to skill development, check out this detailed walkthrough to get started. If you’re an experienced Alexa developer, you can enhance your existing skill by extending it to support the new language model for Italian. This tutorial will show you how you can add support for the Italian model for your existing skills. It will also show you how you can use ASK to enable Alexa to respond based on locales.

You will learn:

  • How to update an Alexa skill for Italian customers using the new Italian language model
  • How to update your AWS Lambda function so your skill delivers the right content to your customers in each of the supported regions—all from a single code base

Part 1: Add the New Language Model for Your Skill

1. Navigate to your existing skill on the Amazon Developer Portal.

2. Click on the language drop down on the top right of the screen and select the last option: “Language Settings.” In this example, the skill already has language models for several English models and Italian.

how to use alexa skills

3. Follow the steps below to complete the Skill Information tab:

how to use alexa skills
how to use alexa skills

  • Click “+ Add New Language”
  • Select “Italian”
  • Click on Save (you will now have the Italian language as an option in the language drop down)

how to use alexa skills

4. Now you will provide the interaction model for the Italian version. You can do this by copying the interaction model from one of the English versions of our skill, and translating the sample utterances and slot values and synonyms. Switch to the US version by clicking on the language dropdown in the skill builder, and choose English (US).

how to use alexa skills

5. Click on Code Editor on the left side bar. This displays the complete interaction model for the skill in JSON format.

how to use alexa skills

6. Select and copy all of the JSON in the code window.

7. Switch back to Italian using the dropdown from Step 4.

8. Click on Code Editor again, and paste the JSON into the code window, replacing the existing JSON.

9. Translate all sample utterances, slot values and slot synonyms.

10. Click on the Save Model button.

11. Click on the Build Model button.

how to use alexa skills

We now have the language model built for Italian. You now need to translate the invocation name, the sample utterances, the slot values and the synonyms. You also must localise the skill meta data, including skill name, description, keywords and, maybe the icon. Skills meta data are available in the “Distribution” tab of the Alexa Developer Console.

In a typical development workflow, you will probably build the skill voice interaction model JSON document programmatically, based on different files you have with sample utterances and slot values. If your interaction model uses any built-in slot types, you may need to make changes to ensure that the types are supported in the locale. For example, the AMAZON.US_FIRST_NAME is supported in English (US), English (UK), English (Canada), and German. An equivalent first name slot type, AMAZON.FirstName, is available for Italian, French, English (India), English (Australia) and Japanese. See the Slot Type Reference for a list of slot types for each supported locale.

Once you have finished translating your interaction model for Italian, you need to customize the responses your skill returns for the different locales that you support. Do this by updating your Lambda function.

Part 2: Update the Lambda Function

Now that your skill is ready to support multiple regions, you may want to update your Lambda function to ensure that your skill provides responses translated or tailored to each supported region. At least, you need to translate to Italian the strings the skill is sending to Alexa to render with the voice of Alexa. You can also use this technique to use different strings for different variation of English. For instance, you may want to greet your customers with “G’day” in Australia, “Hello” in Canada and the UK, “Namaste,” in India, "Hi" in the US, “Bienvenue” in France, and “Buongiorno” in Italy. You can use any localisation library to help you to match strings to locale. Here is an example of how I made it with the ASK Software Development Kit (SDK) for Node.js. For brevity, in this example, all English-based languages are sharing the same set of strings. The code below is based on version 2 of the ASK SDK for Node.js, using the Typescript programming language. It can be easily adapted to other languages.

Step 0: Have a basic string localisation library or class.

For advanced localisation needs, you probably want to use a full fledge localisation library that handles not only strings but also number, date and currency formats. For example AirBnB’s Polyglot, Wikimedia’s i18n, or JQuery’s Globalize.

For simpler requirements, I wrote my own utility class and shared it in the skill audio sample repository. This class resolves locale-specific strings based on a locale code.  It also allows you to substitute in string variables. For brevity and simplicity, the code below is based on this simple string localisation utility class.

Step 1: Set the language strings for each region.

To do this, we define all user-facing language strings in the following format:

how to use alexa skills

As you can see, languageStrings object contains seven objects, one for each supported English language (en-CA, en-US, en-GB, en-IN, and en-AU), one for French and one for Italian. The object keys are identical to the value of the locale property that is passed to our skill when it is invoked by Alexa. This tells us the language model the customer’s device is configured to use so that we can respond with the appropriate string. If you wanted to support German and Japanese, you would add additional objects for 'de-DE' and 'ja-JP' with appropriate translations.

You can see this in action by looking at the JSON request sent to your skill through the service simulator. When testing in the simulator, be sure to select the tab for the language you want to test. In our example, when testing from the Italian language, the request sent to the skill includes the it-IT locale:

how to use alexa skills

Each language has a translations object within languageStrings. This is where we specify any properties that are different for each language. For our example, we have WELCOME_MESSAGE and SKILL_NAME as part of the language strings. You can add more strings as you find relevant.

Step 2: Enable internationalization for your skill.

To use the simple string localisation class in your typescript Intent Handler, import the class in your code’s header. The class will automatically load String.js with your string definitions for each language.

how to use alexa skills
Step 3: Access the language strings in your code.

Once you are done defining and enabling language strings, you can access these strings using the i18n() function. Strings will be rendered in the language that matches the locale of the incoming request. The first parameter is the skill request itself, the utility class will fetch the request locale from there. The second parameter is the key (name) of the string to return. The remaining parameters are an open list of variables to include in the returned string. The i18n() function will substitute these for any {0} placeholder. The number of the parameters must match the number in your placeholders.

This handler for the LaunchRequest retrieves the localized strings for the welcome message and skill greeting, then assembles a complete welcome message for the skill. For a customer using an English (US) device, this would return the speech output "Welcome to My Radio." A customer using an Italian device would receive the speech output “Benvenuto a My Radio.”

how to use alexa skills

That’s all that it takes to update your skill for customers in Italy. We are excited to have Alexa available in Italy, and we can't wait to see what you build.

Check out our documentation to learn more about how you can use ASK to create multi-language Alexa skills.

Get Started

Check out the following training resources, tutorials, and code samples to start building Alexa skills: