Archive

Today, we announced that Amazon Alexa and Alexa-enabled devices are coming to Mexico later this year. Starting today, you can use the Alexa Skills Kit (ASK) to build skills for customers in Mexico using the new Spanish (MX) 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 Spanish (MX) language model. This tutorial will show you how you can add support for the Spanish (MX) 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 Mexican customers using the new Spanish (MX) 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

2. Click on the language drop down on the top right of the screen and select the last option: “Language Settings.”

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

Click “+ Add New Language”

Select “Spanish (MX)”

Click on Save [you will now have the Spanish (MX) language as an option in the language drop down)]

4. Now you need to provide the interaction model for the Spanish (MX) version. One way of doing this is to copy the interaction model for the English versions of the skill, and translate the sample utterances, slot values and synonyms. Make sure to also change any built-in slots and intents to match the new locale. Switch to the US version by clicking on the language dropdown in the skill builder and choose English (US).

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

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

7. Switch back to Spanish(MX) using the dropdown from Step 4.

8. Click on JSON 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.

We now have the language model built for Spanish (MX). You now need to translate the invocation name, the sample utterances, the slot values and the synonyms. You also must localize the skill metadata, including skill name, description, keywords and, maybe, the icon. The skill’s metadata is available in the “Distribution” tab of the Alexa Developer Console.

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 Spanish, 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 Spanish(MX), 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 will need to update your lambda function to ensure that your skill provides responses tailored to each supported region.

At the very least, translate the strings the skill is sending to Alexa to Spanish to be rendered with Alexa's voice. You can also use this technique to use different strings for different variations 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, and “Buenos Dias” in Mexico. The Alexa Skills Kit makes that really simple. Here is an example of how you would do this with the Alexa Skills Kit SDK for Node.js, leveraging the i18next library. For brevity, in this example, all English-based languages are sharing the same set of strings.

Step 1: Set the Language Strings for Each Region

To do this, we define all user-facing language strings in the following format(shortened for legibility):

As you can see, languageStrings object contains an object for each supported language English (en), German (de), and Spanish (es). The object names 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 user’s device is configured to use so that Alexa can respond with the appropriate language. If you wanted to support French and Japanese, you would add additional objects for 'fr' and 'ja' 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 Spanish(MX) language, the request sent to the skill includes the es-MX locale:

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 HELP_MESSAGE and GAME_NAME as part of the language strings. You can add more strings as you find relevant.

Since our interceptor puts all our localized strings in the Request Attributes, when you are done defining and enabling language strings, you can access these strings using the `requestAttributes.t` function. Strings will be rendered in the language that matches the locale of the incoming request.

That’s all that it takes to update your skill to be available for customers in Mexico. We are excited that Alexa is available in Mexico, 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: