How to Update Your Alexa Skills for France

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

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

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

Click “+ Add New Language”

Select “French”

Click Save

4. Provide the interaction model for the French version. Copy the interaction model from one of the English versions of our skill, and translate 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).

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

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:

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:

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.

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