Search in sources :

Example 1 with GetIntentRequest

use of com.google.cloud.dialogflow.cx.v3beta1.GetIntentRequest in project java-dialogflow-cx by googleapis.

the class ITSystemTest method getIntentsTest.

@Test
public void getIntentsTest() {
    GetIntentRequest request = GetIntentRequest.newBuilder().setName(intentsName).build();
    Intent intent = intentsClient.getIntent(request);
    assertIntentDetails(intent);
}
Also used : GetIntentRequest(com.google.cloud.dialogflow.cx.v3beta1.GetIntentRequest) Intent(com.google.cloud.dialogflow.cx.v3beta1.Intent) Test(org.junit.Test)

Example 2 with GetIntentRequest

use of com.google.cloud.dialogflow.cx.v3beta1.GetIntentRequest 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()));
            }
        }
    }
}
Also used : IntentsClient(com.google.cloud.dialogflow.cx.v3.IntentsClient) IntentName(com.google.cloud.dialogflow.cx.v3.IntentName) GetIntentRequest(com.google.cloud.dialogflow.cx.v3.GetIntentRequest) Intent(com.google.cloud.dialogflow.cx.v3.Intent)

Example 3 with GetIntentRequest

use of com.google.cloud.dialogflow.cx.v3beta1.GetIntentRequest in project java-dialogflow by googleapis.

the class ITSystemTest method getIntentTest.

@Test
public void getIntentTest() {
    GetIntentRequest request = GetIntentRequest.newBuilder().setName(intentName.toString()).build();
    Intent actualIntent = intentsClient.getIntent(request);
    assertEquals(intent.getName(), actualIntent.getName());
    assertEquals(intent.getDisplayName(), actualIntent.getDisplayName());
    assertEquals(intent.getAction(), actualIntent.getAction());
    assertEquals(intent.getEvents(0), actualIntent.getEvents(0));
    assertEquals(intent.getEventsCount(), actualIntent.getEventsCount());
}
Also used : GetIntentRequest(com.google.cloud.dialogflow.v2.GetIntentRequest) Intent(com.google.cloud.dialogflow.v2.Intent) Test(org.junit.Test)

Example 4 with GetIntentRequest

use of com.google.cloud.dialogflow.cx.v3beta1.GetIntentRequest 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()));
            }
        }
    }
}
Also used : IntentsClient(com.google.cloud.dialogflow.v2.IntentsClient) IntentName(com.google.cloud.dialogflow.v2.IntentName) GetIntentRequest(com.google.cloud.dialogflow.v2.GetIntentRequest) Intent(com.google.cloud.dialogflow.v2.Intent)

Aggregations

GetIntentRequest (com.google.cloud.dialogflow.v2.GetIntentRequest)2 Intent (com.google.cloud.dialogflow.v2.Intent)2 Test (org.junit.Test)2 GetIntentRequest (com.google.cloud.dialogflow.cx.v3.GetIntentRequest)1 Intent (com.google.cloud.dialogflow.cx.v3.Intent)1 IntentName (com.google.cloud.dialogflow.cx.v3.IntentName)1 IntentsClient (com.google.cloud.dialogflow.cx.v3.IntentsClient)1 GetIntentRequest (com.google.cloud.dialogflow.cx.v3beta1.GetIntentRequest)1 Intent (com.google.cloud.dialogflow.cx.v3beta1.Intent)1 IntentName (com.google.cloud.dialogflow.v2.IntentName)1 IntentsClient (com.google.cloud.dialogflow.v2.IntentsClient)1