How to Update Your Alexa Skills for France

Sebastien Stormacq Mar 13, 2018
Share:
French Tips & Tools
Blog_Header_Post_Img

Today, we announced that Amazon Alexa and Alexa-enabled devices are coming to France later this year. You can start using the Alexa Skills Kit (ASK) to build skills for customers in France with the new French 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 France. This tutorial will show you how you can add support for the French model for your existing skills. It will also show you how you can use the Alexa Skills Kit to have Alexa respond based on locales, and 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. If the Portal lets you select between the old version and the new version, select the new version.

Alexa Blog

2. Click on the language dropdown on the top right of the screen and select the last option: “Language Settings.” In this example, the skill already has language models for English (US), English (UK), English (India), English (Canada), and English (Australia).

Alexa Blog

3. Follow the steps below to complete the Skill Information tab to make the French language as an option in the language dropdown:

Alexa Blog

  • Click “+ Add New Language
  • Select “French
  • Click Save

Alexa Blog
Alexa Blog
Alexa Blog

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

7. Switch back to French 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.

Alexa Blog

We now have the language model built for French. In real 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 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 updating your interaction model for French, you need to customize the responses your skill returns for the different locales that you support. You can 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 tailored to each supported region.

At the very least, translate the strings the skill is sending to Alexa to French to render with the voice of Alexa. 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 “Bienvenue” in France. 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. 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:

Copied to clipboard
const EnglishStrings = {
    "WELCOME_MSG": "Welcome to {{ skillName }}",
    "HELP_MSG": "Welcome to {{ skillName }}. You can play, stop, resume listening.  How can I help you ?",
    "UNHANDLED_MSG" : "Sorry, I could not understand what you've just said.",
    "RESUME_MSG" : "Resuming {{ skillName }}",
    "STOP_MSG" : "Goodbye."
};
const FrenchStrings = {
    "WELCOME_MSG": "Bienvenue sur {{ skillName }}",
    "HELP_MSG": "Bienvenue sur {{ skillName }}. Vous pouvez démarrer, arrêter ou reprendre.  Que souhaitez-vous faire ?",
    "UNHANDLED_MSG" : "Désolé, je n'ai pas compris ce que vous avez dit.",
    "RESUME_MSG" : "Je redémarre {{ skillName }}",
    "STOP_MSG" : "au revoir !"
};
const languageString = {
    "en-GB": {
        "translation": EnglishStrings
    },
    "en-US": {
        "translation": EnglishStrings
    },
    "en-IN": {
        "translation": EnglishStrings
    },
    "en-CA": {
        "translation": EnglishStrings
    },
    "en-AU": {
        "translation": EnglishStrings
    },
    "fr-FR": {
        "translation": FrenchStrings
    }
};

As you can see, languageStrings object contains six objects, one for each supported English language (en-CA, en-US, en-GB, en-IN, and en-AU) and one for French. 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 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 French language, the request sent to the skill includes the fr-FR 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 Using the Alexa Skills Kit SDK

To enable string internationalization features in alexa-sdk, we set resources to the languageStrings object we created above:

Copied to clipboard
exports.handler = (event, context, callback) => {

    var skill = alexa.handler(event, context, callback);
    skill.appId = constants.appId;

    // To enable string internationalization (i18n) features,
    // set a resources object.
    skill.resources = languageStrings;
    
    skill.registerHandlers( handler );
    skill.execute();
};
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 this.t() function. Strings will be rendered in the language that matches the locale of the incoming request.

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 Maxi 80" while for a customer using a French device, this same code would return the speech output “Bienvenue sur Maxi 80”.

Copied to clipboard
'LaunchRequest': function () {
        this.response
            .speak(this.t('WELCOME_MSG'))
            .listen(this.t('HELP_MSG'));
    
        this.emit(':responseReady');
    }

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

Check out our documentation on developing skills in multiple languages to learn more about how you can use the Alexa Skills Kit to create multi-language skills.

Learn More

Useful Blog Posts

SDKs