Using i18n with Dialogflow API only returns keys

dialogflow
google-assistant

#1

Hey everybody :call_me_hand:,

currently I am developing a dialog system for Alexa & Google Assistant which both work fine deployed on AWS lambda and using i18n for string managmenet and multiple languages.

Now I want to use the Dialogflow API V2 to integrate the system into an IONIC app. The Dialogflow API can be tested with the Dialogflow Console, where you can enter a text query and get the server response, as you can see in the image below:

The JSON from the API response should contain different information (more info here), like the recognized intent and the response text.

Now, when I query some text to my dialog service via the API, I get the correct Intent recognition from the API but with wrong values in the “fulfillmentText” field of the response, which actually should contain the dialog response text of the corresponding intent. I receive the response of the intent but where i18n keys did not get replaced by the corresponding strings.

So my i18n file looks like this:

// en-US.json
{
  "translation": {
    "welcome": "Welcome to this great Voice App! Ask me anything!", 
    // ...
    }
}

and when I call the API this:

POST https://dialogflow.googleapis.com/v2/projects/<project-id>/agent/sessions/<client-id>:detectIntent

and the query text, that calls this.tell(this.t("welcome")) in the body (here: “Start my Voice App”), I get the following response:

{
  "responseId": "XXXXXXX...XXXX",
  "queryResult": {
    "queryText": "start my voice app",
    "parameters": {},
    "allRequiredParamsPresent": true,
    "fulfillmentText": "welcome",
    "fulfillmentMessages": [
      {
        "text": {
          "text": [
            "welcome"
          ]
        }
      }
    ],
// ...
}

where fulfillmentText should actually contain the string “Welcome to this great Voice App! Ask me anything!” and not the i18n key welcome.


Now to the scary part: :sleepy:
I found out, when I test the dialog with the Google Assistant Simulator, this behaviour changes and everything is fine - in the Google Assistant and in the dialogflow API for about 10 minutes. Afterwards, the API again only returns the i18n keys instead of replacing them with the text.

So going to the Google Asstant simulator…


and starting the dialog works fine. Then returning to the API and requesting with the same data as above, gives the follwoing correct response:

{
  "responseId": "XXXX...XXXX",
  "queryResult": {
    "queryText": "start my voice app",
    "parameters": {},
    "allRequiredParamsPresent": true,
    "fulfillmentText": "Welcome to this great Voice App! Ask me anything!",
    "fulfillmentMessages": [
      {
        "text": {
          "text": [
            "Welcome to this great Voice App! Ask me anything!"
          ]
// ...
}

After about 10min, I have to call the Google Assistant Simulator again, otherwise I will again receive the false response from the API.


The naming issue of Dialogflow with en.json and en-US.json already got checked by me, as well as any language matching issues.

To make it clear: The problem vanishes for about 10min when the dialog is called using the Google Assistant simulator and only appears, when using the Dialogflow API.

So it seems to be a session issue with i18n or something…? :thinking:

Any ideas? - thank you