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.
@google-cloud/dialogflow version: 3.3.0{
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: []
}
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
}
return new Promise(resolve => {
this.intentsClient
.batchUpdateIntents(intentRequest)
.then(responses => {
resolve(responses[0])
})
.catch(err => {
console.error(err)
resolve({})
})
})
My Dialogflow agent has been updated with the new training phrases:
@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:

After the update:

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

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):

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