How to Update Your Alexa Skills for Mexico

Memo Doring Aug 08, 2018
Tips & Tools Spanish

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:

  1. How to update an Alexa skill for Mexican customers using the new Spanish (MX) language model
  2. 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.”

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 “Spanish (MX)”
  • Click on Save [you will now have the Spanish (MX) language as an option in the language drop down)]

how to use alexa skills

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).

how to use alexa skills

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

how to use alexa skills

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):

Copied to clipboard
const languageString = {
  en: {
    translation: {
      GAME_NAME: 'Reindeer Trivia',
      HELP_MESSAGE: 'I will ask you %s multiple choice questions. Respond with the number of the answer. For example, say one, two, three, or four. To start a new game at any time, say, start game. ',
  de: {
  translation: {
    GAME_NAME: 'Wissenswertes über Rentiere in Deutsch',
    HELP_MESSAGE: 'Ich stelle dir %s Multiple-Choice-Fragen. Antworte mit der Zahl, die zur richtigen Antwort gehört. Sage beispielsweise eins, zwei, drei oder vier. Du kannst jederzeit ein neues Spiel beginnen, sage einfach „Spiel starten“. ',
  translation: {
    GAME_NAME: 'Trivia de Renos',
    HELP_MESSAGE: 'Voy a hacerte %s preguntas de opcion multiple. Responde con el numero de la respuesta, por favor. Por ejemplo, di uno, dos, tres o cuatro. Para comenzar un nuevo juego, di nuevo juego en cualquier momento.',

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:

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

Step 2: Enable Internationalization for Your Skill Using the Alexa Skills Kit SDK

To enable string internationalization features in the current version of the ask-sdk, we will do three things:

1. Import an external library, we picked i18next for this example

Copied to clipboard
const i18n = require('i18next');
const sprintf = require('i18next-sprintf-postprocessor');

2. Create a Request Interceptor to make sure every request gets processed

Copied to clipboard
const LocalizationInterceptor = {
  process(handlerInput) {
    const localizationClient = i18n.use(sprintf).init({
      lng: handlerInput.requestEnvelope.request.locale,
      overloadTranslationOptionHandler: sprintf.overloadTranslationOptionHandler,
      resources: languageString,
      returnObjects: true

    const attributes = handlerInput.attributesManager.getRequestAttributes();
    attributes.t = function (...args) {
      return localizationClient.t(...args);

3. Register the Interceptor

Copied to clipboard
const skillBuilder = Alexa.SkillBuilders.custom();
exports.handler = skillBuilder
Step 3: Access the Language Strings in Your Code

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: