use of com.google.cloud.dialogflow.cx.v3.IntentName in project java-dialogflow-cx by googleapis.
the class ListTrainingPhrases method listTrainingPhrases.
// DialogFlow API List Training Phrases sample.
public static void listTrainingPhrases(String projectId, String location, String agentId, String intentId) throws IOException {
try (IntentsClient client = IntentsClient.create()) {
// Set the intent name
IntentName name = IntentName.of(projectId, location, agentId, intentId);
// Compose the get-intent request
GetIntentRequest request = GetIntentRequest.newBuilder().setName(name.toString()).build();
// Make API request to get intent
Intent response = client.getIntent(request);
// Loop through the results
for (Intent.TrainingPhrase phrase : response.getTrainingPhrasesList()) {
System.out.println("***********************************************");
List<Intent.TrainingPhrase.Part> parts = phrase.getPartsList();
for (Intent.TrainingPhrase.Part part : parts) {
System.out.println(String.format("Training Phrase: %s", part.getText()));
}
}
}
}
use of com.google.cloud.dialogflow.cx.v3.IntentName in project java-dialogflow by googleapis.
the class IntentManagement method deleteIntent.
// [END dialogflow_create_intent]
// [START dialogflow_delete_intent]
/**
* Delete intent with the given intent type and intent value
*
* @param intentId The id of the intent.
* @param projectId Project/Agent Id.
*/
public static void deleteIntent(String intentId, String projectId) throws ApiException, IOException {
// Instantiates a client
try (IntentsClient intentsClient = IntentsClient.create()) {
IntentName name = IntentName.of(projectId, intentId);
// Performs the delete intent request
intentsClient.deleteIntent(name);
}
}
use of com.google.cloud.dialogflow.cx.v3.IntentName in project java-dialogflow by googleapis.
the class ListTrainingPhrases method listTrainingPhrases.
// DialogFlow API List Training Phrases sample.
public static void listTrainingPhrases(String projectId, String intentId) throws IOException {
try (IntentsClient client = IntentsClient.create()) {
// Set the intent name
IntentName name = IntentName.of(projectId, intentId);
// Compose the get-intent request
GetIntentRequest request = GetIntentRequest.newBuilder().setName(name.toString()).setIntentView(IntentView.INTENT_VIEW_FULL).build();
// Make API request to update intent
Intent response = client.getIntent(request);
// Loop through the results
for (Intent.TrainingPhrase phrase : response.getTrainingPhrasesList()) {
System.out.println("***********************************************");
System.out.println(String.format("Phrase ID: %s", phrase.getName()));
List<Intent.TrainingPhrase.Part> parts = phrase.getPartsList();
for (Intent.TrainingPhrase.Part part : parts) {
System.out.println(String.format("Training Phrase: %s", part.getText()));
}
}
}
}
Aggregations