Today, we announced that Amazon Alexa and Alexa-enabled devices are coming to Australia and New Zealand in early 2018. Starting today, you can use the Alexa Skills Kit (ASK) to build skills for customers in these countries using the new English (Australia) 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 Australia. This tutorial will show you how you can add support for the English (Australia) model for your existing skills. It will also show you how you can use the Alexa Skills Kit to respond based on locales.
We now have the language model built for English (Australia). Since we just copied and pasted the entire interaction model from English (US), all your intents, sample utterances, and custom slot values are identical for both languages. You can edit these elements separately if you want – for example, you might want to provide locale-specific sample utterances. Add and edit your sample utterances in skill builder normally. Your interaction model changes are specific to the selected locale.
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 (U.S.), English (U.K.), English (Canada), and German. An equivalent first name slot type, AMAZON.FirstName, is available for 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 English (Australia), you need to customize the responses your skill returns for the different locales that you support. Do this by updating your 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.
For instance, you may want to greet your customers with “G’day” in Australia, “Hello” in Canada and the UK, “Namaste,” in India, and "Hi" in the US. 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.
To do this, we define all user-facing language strings in the following format:
var languageStrings = {
'en-AU': {
translation:{
SKILL_NAME: 'Australian Quotes',
SKILL_GREETING: 'G\'day',
WELCOME_MESSAGE: '%s! You can ask me for an inspirational quote.',
PERSONALIZED_INTRO: "%s, here is your quote for today: ",
}
},
'en-CA': {
translation: {
SKILL_NAME: 'Canadian Quotes',
SKILL_GREETING: 'Hello',
WELCOME_MESSAGE: '%s. You can ask me for an inspirational quote.',
PERSONALIZED_INTRO: "%s, here is your quote for today: "
},
},
'en-US': {
translation: {
SKILL_NAME: 'American Quotes',
SKILL_GREETING: 'Hi',
WELCOME_MESSAGE: '%s! You can ask me for an inspirational quote.',
PERSONALIZED_INTRO: "%s, here is your quote for today: "
},
},
'en-IN': {
translation: {
SKILL_NAME: 'Indian Quotes',
SKILL_GREETING: 'Namaste',
WELCOME_MESSAGE: '%s! You can ask me for an inspirational quote.',
PERSONALIZED_INTRO: "%s, here is your quote for today: "
},
},
'en-GB': {
translation: {
SKILL_NAME: 'British Quotes',
SKILL_GREETING: 'Hello'
WELCOME_MESSAGE: '%s. You can ask me for an inspirational quote.',
PERSONALIZED_INTRO: "%s, here is your quote for today: "
},
}
};
As you can see, languageStrings
object contains five objects, one for each supported English language (en-CA, en-US, en-GB, en-IN, and now en-AU). 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 end user’s device is configured to use so that we 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 English (Australia) tab, the request sent to the skill includes the en-AU 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 SKILL_GREETING and SKILL_NAME as part of the language strings. You can add more strings as you find relevant. Since this “daily inspiration” example is a skill that provides quotations, you can create different sets of inspirational quotes for each locale.
To enable string internationalization (i18n) features in Alexa-sdk
, we set resources to the languageStrings
object we created above:
exports.handler = function (event, context) {
const alexa = Alexa.handler(event, context);
alexa.APP_ID = APP_ID;
// To enable string internationalization (i18n) features, set a resources object.
alexa.resources = languageStrings;
alexa.registerHandlers(handlers);
alexa.execute();
};
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 an English (Australia) skill, this would return the speech output: "G’day! You can ask me for an inspirational quote," while for an English (India) skill, this same code would return the speech output “Namaste! You can ask me for an inspirational quote.”
'LaunchRequest': function () {
this.attributes.speechOutput = this.t('WELCOME_MESSAGE', this.t('SKILL_GREETING'));
this.attributes.repromptSpeech =
this.t('HELP_REPROMPT');
this.response
.speak(this.attributes.speechOutput)
.listen(this.attributes.repromptSpeech);
this.emit(':responseReady');
}
That’s all that it takes to update your skill to be available for customers in Australia and New Zealand.
We are excited to have Alexa available in Australia and New Zealand, 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.