Nodejs-dialogflow: BUG: batchUpdateIntents seems to ignore the languageCode param when updating intents training phrases

Created on 9 Nov 2020  路  8Comments  路  Source: googleapis/nodejs-dialogflow

I want to add training phrases to multiple intents for several languages. To do so I tried to use batchUpdateIntents for each language but I can't manage to make it work only for the languageCode specify in the query.
Even if I specify a languageCode in the request, it still updates all the languages in Dialogflow with the training phrases sent.

I have a Dialogflow agent that has 3 language codes activated: 'fr', 'fr-FR', 'en-US'.
All my intents have training phrases for both 'fr-FR' and 'en-US'.

When I'm sending a request with languageCode: 'fr-FR', the training phrases of the intents from both 'fr-FR' and 'en-US' are updated with the 'fr-FR' training phrases sent. Same thing when languageCode: 'en-US'.
It seems like the languageCode is ignored and the changes are applied to all the languages.

Exception: 'fr' language, which did not have any training phrases in any of my intents, was not affected by the request. It still didn't have any training phrases. Only languages that already had training phrases were updated.

Environment details

  • OS: macOS Catalina
  • Node.js version: v14.15.0
  • npm version: v6.14.8
  • @google-cloud/dialogflow version: 3.3.0

Steps to reproduce

  1. format the intents following the documentation (https://googleapis.dev/nodejs/dialogflow/latest/google.cloud.dialogflow.v2beta1.IIntent.html) such as:
{
  displayName: 'my_intent',
  name: 'projects/my-project-id/agent/intents/my-intent-id',
  webhookState: 'WEBHOOK_STATE_DISABLED',
  mlEnabled: true,
  priority: 500000,
  trainingPhrases: [
    { type: 'TYPE_EXAMPLE', parts: [Array] },
    { type: 'TYPE_EXAMPLE', parts: [Array] }
  ],
  parameters: []
}
  1. format the request such as:
const intentRequest = {
  parent: 'projects/my-project-id/agent',
  intentBatchInline: {
    intents: [ [Object], [Object], [Object], [Object], [Object], [Object] ] // intents formatted in step 1
  },
  languageCode: 'fr-FR',
  updateMask: { paths: [ 'training_phrases' ] } // I tried with and without this param but it makes no difference
}
  1. send the request:
return new Promise(resolve => {
      this.intentsClient
        .batchUpdateIntents(intentRequest)
        .then(responses => {
          resolve(responses[0])
        })
        .catch(err => {
          console.error(err)
          resolve({})
        })
    })

Expected result

My Dialogflow agent has been updated with the new training phrases:

  • fr-FR training phrases updated with the fr-FR training phrases from the request
  • en-US training phrases updated with the en-US training phrases from the request
investigating p2 bug dialogflow

All 8 comments

@codebynao I will try to repro this on my end to see if I can get a same error.

@codebynao I was able to repro your issue. I am waiting for response back from the dialogflow team.

Great thanks!

Hi @munkhuushmgl , any news about this issue ?
Thanks !

I gave this a shot and it worked for an Intent that I created in the UI but didn't add any training phrases...

curl -X POST \
-H "Authorization: Bearer "$(gcloud auth print-access-token --impersonate-service-account=[YOUR_SERVICeACCOUNT]@dialogflow-cx-first-run.iam.gserviceaccount.com) \
-H "Content-Type: application/json; charset=utf-8" \
-d '{
        "intentBatchInline": {
            "intents": [
                {
                    "name":"projects/dialogflow-cx-first-run/agent/intents/[YOUR_INTENT_ID]",
                    "displayName":"batchupdate_test",
                    "trainingPhrases": [
                        {
                            "type": "EXAMPLE",
                            "parts": [
                                {
                                    "text": "The rain in spain "
                                },
                                {
                                    "text": "is mainly on the Plain."
                                }
                            ]
                        }
                    ]
                }
            ]
        }
    }' \
https://dialogflow.googleapis.com/v2beta1/projects/dialogflow-cx-first-run/agent/intents:batchUpdate

The response I got back:
image

After the update:
image

I added German as a language.
Confirmed that the intent in en had a training phrase but in de was empty:
en:
image.png
image

Ran the following to add a training phrase to the german intent:
"""
curl -X POST \
-H "Authorization: Bearer "$(gcloud auth print-access-token --impersonate-service-account=[YOUR_SERVICe_ACCOUNT].gserviceaccount.com) \
-H "Content-Type: application/json; charset=utf-8" \
-d '{
"languageCode": "de",
"intentBatchInline": {
"intents": [
{
"name":"projects/dialogflow-cx-first-run/agent/intents/[YOUR_INTENT_ID]",
"displayName":"batchupdate_test_2",
"trainingPhrases": [
{
"type": "EXAMPLE",
"parts": [
{
"text": "ich "
},
{
"text": "mag Schokolade"
}
]
}
]
}
]
}
}' \
https://dialogflow.googleapis.com/v2beta1/projects/dialogflow-cx-first-run/agent/intents:batchUpdate
"""

and it worked, only DE was updated, EN stayed the same (as expected):
image

So sorry it actually seems to work 馃槄 we missed an error in our code that caused the issue! Thanks for your answer!!

Was this page helpful?
0 / 5 - 0 ratings