Closed jrglg closed 2 years ago
Hey @jrglg
Renaming locale
to localeId
in the config does make sense to me. We'll discuss it with the team.
Unfortunately, Amazon uses different formats in its products. Lex uses es_ES
, Alexa es-ES
. For now, you can hard code the locale
property in your Lex config to es_ES
.
Feature suggestion:
Add a locale map to the Lex integration:
Example:
localeMap: {
'es': 'es_ES'
}
This would map the request locale (e.g. es
) to 'es_ES` which is compatible with Lex
@aswetlow
I suggest something like this:
localeMap: { 'en': 'en_US', 'default': 'en_US' }
The logic for selecting the localeId would be:
private getLocale(request: JovoRequest): string {
const DEFAULT_KEY = 'default';
const key = request.getLocale() || DEFAULT_KEY;
const locale = this.config.localeMap[key] || this.config.localeMap[DEFAULT_KEY] || 'en_US';
return locale;
}
@aswetlow @jrglg Created a PR for this.
Thank you @rmtuckerphx 🎉
This was merged and released yesterday.
I'm submitting a...
Expected Behavior
Using Lex in Jovo Debugger should work well.
Current Behavior
With default configuration from Jovo docs for Lex, some errors are thrown that can make you think that the configuration of the bot or AWS is wrong. The
locale
attribute is needed to avoid this. If not specified, then the following method has to be adapted, becausejovo.$request.getLocale()
doesn't stick to the convention: https://docs.aws.amazon.com/lexv2/latest/dg/how-languages.htmlSo I would change the name of the
locale
attribute tolocaleId
, and then add it to the docs at: https://www.jovo.tech/marketplace/slu-lex#configurationWhat's happening:
Testing my bot from the Lex simulator, I see these requests are sent:
But, from LexSlu.ts, when generating the params object for the command: https://github.com/jovotech/jovo-framework/blob/fcadf2892b4ae61ac185fda91a398df371f64e36/integrations/slu-lex/src/LexSlu.ts#L124
an incorrect localeId is passed: "es", in my case. It should be "es_ES", as in the simulator and in: https://docs.aws.amazon.com/lexv2/latest/dg/how-languages.html
Error log
Your Environment