|
| 1 | +# Copyright 2021 Google LLC |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# https://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | + |
| 15 | +# [START dialogflow_list_training_phrases] |
| 16 | + |
| 17 | + |
| 18 | +def list_training_phrases(project_id, agent_id, intent_id, location): |
| 19 | + """Returns all training phrases for a specified intent.""" |
| 20 | + |
| 21 | + from google.cloud import dialogflowcx |
| 22 | + |
| 23 | + # Create the intents client |
| 24 | + intent_client = dialogflowcx.IntentsClient() |
| 25 | + |
| 26 | + # Specify working intent |
| 27 | + intent_name = intent_client.intent_path(project_id, location, agent_id, intent_id) |
| 28 | + |
| 29 | + # Compose the get-intent request |
| 30 | + get_intent_request = dialogflowcx.GetIntentRequest(name=intent_name) |
| 31 | + |
| 32 | + intent = intent_client.get_intent(get_intent_request) |
| 33 | + |
| 34 | + # Iterate through the training phrases. |
| 35 | + for phrase in intent.training_phrases: |
| 36 | + print(phrase) |
| 37 | + |
| 38 | + return intent.training_phrases |
| 39 | + |
| 40 | + |
| 41 | +# [END dialogflow_list_training_phrases] |
0 commit comments