Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Training phrases are not returned via python API

fh2
Bronze 1
Bronze 1

I am trying to get an overview of the training phrases per intent from Dialogflow in python. However, for every intent I get an empty list when accessing the training phrases (while I can see the training phrases in the portal). A more extensive description of this issue can be found

here: https://stackoverflow.com/questions/76153606/dialogflow-doesnt-return-training-phrases.

 

Solved Solved
0 10 601
1 ACCEPTED SOLUTION

fh2
Bronze 1
Bronze 1

The solution for getting all the training phrases per intent was to pass the intent_view="INTENT_VIEW_FULL" to the request. In the stackoverflow post, a full code snippet can be found (https://stackoverflow.com/questions/76153606/dialogflow-doesnt-return-training-phrases/)

View solution in original post

10 REPLIES 10

Hi the parent ID is wrong. Use this code:

    parent = dialogflow.AgentsClient.agent_path(project_id)

    intents
= intents_client.list_intents(request={"parent": parent})

You have more examples here: https://cloud.google.com/dialogflow/es/docs/how/manage-intents?hl=es-419#list-intent-python

thanks! 

Thank you for your reply! However, the same behavior occurs when I use your code snippet. As with the original piece of code, the intent name, and intent display name are printed as expected, but the training phrases are an empty list. 

mmm, interesting.

Did you check the permissions etc?

In the Google Cloud Console, I found that the principal making the request has the following roles: Dialogflow API Admin (161/165 excess permissions), Dialogflow API Client (25/26 excess permissions). And now I've added Dialogflow Intent Admin, but still no training phrases are returned. Are there any other roles the principal should have?

Just with the admin one should be good. Are you using the REST client or the GRPC one? Sometimes I had issues ith the REST one and I had to use the GRPC one

I am using the following client library for python: google-cloud-dialogflow==2.11.0. The snippet of my code can be found here:  https://stackoverflow.com/questions/76153606/dialogflow-doesnt-return-training-phrases.

I would suggest to try with the latest version 2.21.0

Unfortunately, still no training phrases with the upgraded package.

fh2
Bronze 1
Bronze 1

The solution for getting all the training phrases per intent was to pass the intent_view="INTENT_VIEW_FULL" to the request. In the stackoverflow post, a full code snippet can be found (https://stackoverflow.com/questions/76153606/dialogflow-doesnt-return-training-phrases/)

OH MY! Glad to see the final solution! Also Glad to see that the Dialogflow CX libraries are more intuitive!