jovotech / jovo-framework

🔈 The React for Voice and Chat: Build Apps for Alexa, Messenger, Instagram, the Web, and more
https://www.jovo.tech
Apache License 2.0
1.68k stars 309 forks source link

Dialogflow requires entity/intent json for both language (e.g. es) and locale (e.g. es-ES) #684

Closed finnbear closed 2 years ago

finnbear commented 4 years ago

I'm submitting a...

Expected Behavior

image If I create two i18n src files and two model files, en-US.json and es-ES.json, Jovo should do what is necessary for Dialogflow to recognize Spanish as a 2nd supported language. Specifically, instead of only creating *_es.json (entities and intents), create *_es-es.json which may be a duplicate of *_es.json.

I am basing this understanding on exporting my agent from Dialogflow after manually setting es -> es-ES as a language: image

Side note: Dialogflow seems to prefer es and es-ES to both be present, as this is how exported agents that were manually set to support es -> es-ES are configured:

"supportedLanguages": [
    "en-us",
    "es", <-- Jovo doesn't add this but it may be necessary for next item to work
    "es-es",
]

Current Behavior

image Regardless of the configured supportedLanguages in agent.json, Dialogflow ends up only recognizing one language and locale, en -> en-US

The issue seems to be that jovo only exports *_es.json but not *_es-es.json. When Dialogflow can't find *_es-es.json entities and intents, it disables support for es -> es_ES. image

I considered manually duplicating my es-ES.json into es.json but that wouldn't work because es-ES.json is already converted to *_es.json, not *_es-es.json.

Your Environment

Configuration

config.js module.exports = { logging: true, intentMap: { 'AMAZON.StopIntent': 'END', }, i18n: { fallbackLng: { 'en': ['en-US'], 'default': ['en-US'] } } };
project.js module.exports = { alexaSkill: { nlu: { name: 'alexa' } }, googleAction: { nlu: { name: 'dialogflow', agent: { supportedLanguages: [ "en-us", "es", "es-es" ] } } }, defaultStage: 'dev', stages: { dev: { endpoint: '${JOVO_WEBHOOK_URL}' }, prod: { alexaSkill: { endpoint: "arn:aws:lambda:us-XXX-X:XXXX:function:jovo-voice-app" }, googleAction: { dialogflow: { endpoint: "https://XXXXXX.execute-api.us-XXXX-X.amazonaws.com/prod", keyFile: "./google-action-key.json", projectId: "jovo-voice-app-XXXXXX" }, host: { lambda: { arn: 'arn:aws:lambda:us-XXXX-X:XXXX:function:jovo-voice-app' } } } } } }
finnbear commented 4 years ago

Just noticed that in the i18n code example, the non-English language is named two different things:

The model is called de-DE.json: https://github.com/jovotech/jovo-framework/blob/master/examples/javascript/i18n/models/de-DE.json

But the translation is called de.js: https://github.com/jovotech/jovo-framework/blob/master/examples/javascript/i18n/src/i18n/de.js

English, by contrast, has en-US in the filename for both model and translation. What is the intention behind the difference?

I also notice that this example has only one intent:

app.setHandler({
    LAUNCH() {
        // this.$speech.t('WELCOME_ARRAY');
        // return this.tell(this.$cms.resources);
        console.log(this.t('WELCOME_GLOBAL'));
        this.tell(this.t('WELCOME'));
    },
});

My launch intent does work, and I fully believe this example's launch intent would work too. However, if it isn't already, the case of multiple intents with multiple languages should be documented (and demonstrated in examples).

aswetlow commented 2 years ago

I close this issue due to inactivity.