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());
}
}
Aggregations