Search in sources :

Example 1 with ConversationProfile

use of com.google.cloud.dialogflow.v2.ConversationProfile in project java-dialogflow by googleapis.

the class ConversationProfilesClientTest method listConversationProfilesTest3.

@Test
public void listConversationProfilesTest3() throws Exception {
    ConversationProfile responsesElement = ConversationProfile.newBuilder().build();
    ListConversationProfilesResponse expectedResponse = ListConversationProfilesResponse.newBuilder().setNextPageToken("").addAllConversationProfiles(Arrays.asList(responsesElement)).build();
    mockConversationProfiles.addResponse(expectedResponse);
    String parent = "parent-995424086";
    ListConversationProfilesPagedResponse pagedListResponse = client.listConversationProfiles(parent);
    List<ConversationProfile> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getConversationProfilesList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockConversationProfiles.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListConversationProfilesRequest actualRequest = ((ListConversationProfilesRequest) actualRequests.get(0));
    Assert.assertEquals(parent, actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ListConversationProfilesPagedResponse(com.google.cloud.dialogflow.v2.ConversationProfilesClient.ListConversationProfilesPagedResponse) Test(org.junit.Test)

Example 2 with ConversationProfile

use of com.google.cloud.dialogflow.v2.ConversationProfile in project java-dialogflow by googleapis.

the class ConversationProfileManagement method createConversationProfileArticleSuggestion.

// Create a conversation profile with given values about Article Suggestion.
public static void createConversationProfileArticleSuggestion(String projectId, String displayName, String location, Optional<String> articleSuggestionKnowledgeBaseId) throws ApiException, IOException {
    try (ConversationProfilesClient conversationProfilesClient = ConversationProfilesClient.create()) {
        // Create a builder for agent assistance configuration
        SuggestionConfig.Builder suggestionConfigBuilder = SuggestionConfig.newBuilder();
        // Add knowledge base for Article Suggestion feature
        if (articleSuggestionKnowledgeBaseId.isPresent()) {
            KnowledgeBaseName articleSuggestionKbName = KnowledgeBaseName.of(projectId, articleSuggestionKnowledgeBaseId.get());
            // Build configuration for Article Suggestion feature
            SuggestionFeatureConfig articleSuggestionFeatureConfig = SuggestionFeatureConfig.newBuilder().setSuggestionFeature(SuggestionFeature.newBuilder().setType(Type.ARTICLE_SUGGESTION).build()).setSuggestionTriggerSettings(buildSuggestionTriggerSettings()).setQueryConfig(buildSuggestionQueryConfig(articleSuggestionKbName)).build();
            // Add Article Suggestion feature to agent assistance configuration
            suggestionConfigBuilder.addFeatureConfigs(articleSuggestionFeatureConfig);
        }
        LocationName locationName = LocationName.of(projectId, location);
        // Set a conversation profile with target configurations
        ConversationProfile targetConversationProfile = ConversationProfile.newBuilder().setDisplayName(displayName).setLanguageCode("en-US").setHumanAgentAssistantConfig(HumanAgentAssistantConfig.newBuilder().setHumanAgentSuggestionConfig(suggestionConfigBuilder.build())).build();
        // Create a conversation profile
        ConversationProfile createdConversationProfile = conversationProfilesClient.createConversationProfile(CreateConversationProfileRequest.newBuilder().setParent(locationName.toString()).setConversationProfile(targetConversationProfile).build());
        System.out.println("====================");
        System.out.println("Conversation Profile created:\n");
        System.out.format("Display name: %s\n", createdConversationProfile.getDisplayName());
        System.out.format("Name: %s\n", createdConversationProfile.getName());
    }
}
Also used : ConversationProfile(com.google.cloud.dialogflow.v2.ConversationProfile) SuggestionConfig(com.google.cloud.dialogflow.v2.HumanAgentAssistantConfig.SuggestionConfig) SuggestionFeatureConfig(com.google.cloud.dialogflow.v2.HumanAgentAssistantConfig.SuggestionFeatureConfig) ConversationProfilesClient(com.google.cloud.dialogflow.v2.ConversationProfilesClient) KnowledgeBaseName(com.google.cloud.dialogflow.v2.KnowledgeBaseName) LocationName(com.google.cloud.dialogflow.v2.LocationName)

Example 3 with ConversationProfile

use of com.google.cloud.dialogflow.v2.ConversationProfile in project java-dialogflow by googleapis.

the class ConversationProfilesClientTest method listConversationProfilesTest.

@Test
public void listConversationProfilesTest() throws Exception {
    ConversationProfile responsesElement = ConversationProfile.newBuilder().build();
    ListConversationProfilesResponse expectedResponse = ListConversationProfilesResponse.newBuilder().setNextPageToken("").addAllConversationProfiles(Arrays.asList(responsesElement)).build();
    mockConversationProfiles.addResponse(expectedResponse);
    LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
    ListConversationProfilesPagedResponse pagedListResponse = client.listConversationProfiles(parent);
    List<ConversationProfile> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getConversationProfilesList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockConversationProfiles.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListConversationProfilesRequest actualRequest = ((ListConversationProfilesRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ListConversationProfilesPagedResponse(com.google.cloud.dialogflow.v2.ConversationProfilesClient.ListConversationProfilesPagedResponse) Test(org.junit.Test)

Example 4 with ConversationProfile

use of com.google.cloud.dialogflow.v2.ConversationProfile in project java-dialogflow by googleapis.

the class ConversationProfilesClientTest method listConversationProfilesTest2.

@Test
public void listConversationProfilesTest2() throws Exception {
    ConversationProfile responsesElement = ConversationProfile.newBuilder().build();
    ListConversationProfilesResponse expectedResponse = ListConversationProfilesResponse.newBuilder().setNextPageToken("").addAllConversationProfiles(Arrays.asList(responsesElement)).build();
    mockConversationProfiles.addResponse(expectedResponse);
    ProjectName parent = ProjectName.of("[PROJECT]");
    ListConversationProfilesPagedResponse pagedListResponse = client.listConversationProfiles(parent);
    List<ConversationProfile> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getConversationProfilesList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockConversationProfiles.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListConversationProfilesRequest actualRequest = ((ListConversationProfilesRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ListConversationProfilesPagedResponse(com.google.cloud.dialogflow.v2.ConversationProfilesClient.ListConversationProfilesPagedResponse) Test(org.junit.Test)

Aggregations

ListConversationProfilesPagedResponse (com.google.cloud.dialogflow.v2.ConversationProfilesClient.ListConversationProfilesPagedResponse)3 AbstractMessage (com.google.protobuf.AbstractMessage)3 Test (org.junit.Test)3 ConversationProfile (com.google.cloud.dialogflow.v2.ConversationProfile)1 ConversationProfilesClient (com.google.cloud.dialogflow.v2.ConversationProfilesClient)1 SuggestionConfig (com.google.cloud.dialogflow.v2.HumanAgentAssistantConfig.SuggestionConfig)1 SuggestionFeatureConfig (com.google.cloud.dialogflow.v2.HumanAgentAssistantConfig.SuggestionFeatureConfig)1 KnowledgeBaseName (com.google.cloud.dialogflow.v2.KnowledgeBaseName)1 LocationName (com.google.cloud.dialogflow.v2.LocationName)1