Search in sources :

Example 1 with SuggestionFeatureConfig

use of com.google.cloud.dialogflow.v2.HumanAgentAssistantConfig.SuggestionFeatureConfig 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)

Aggregations

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