use of com.google.cloud.dialogflow.v2.Intent.Builder in project java-dialogflow by googleapis.
the class UpdateIntent method updateIntent.
// DialogFlow API Update Intent sample.
public static void updateIntent(String projectId, String intentId, String location, String displayName) throws IOException {
try (IntentsClient client = IntentsClient.create()) {
String intentPath = "projects/" + projectId + "/locations/" + location + "/agent/intents/" + intentId;
Builder intentBuilder = client.getIntent(intentPath).toBuilder();
intentBuilder.setDisplayName(displayName);
FieldMask fieldMask = FieldMask.newBuilder().addPaths("display_name").build();
Intent intent = intentBuilder.build();
UpdateIntentRequest request = UpdateIntentRequest.newBuilder().setIntent(intent).setLanguageCode("en").setUpdateMask(fieldMask).build();
// Make API request to update intent using fieldmask
Intent response = client.updateIntent(request);
System.out.println(response);
}
}
use of com.google.cloud.dialogflow.v2.Intent.Builder in project java-dialogflow by googleapis.
the class SetAgent method setAgent.
public static Agent setAgent(String parent, String displayName) throws IOException {
AgentsSettings agentsSettings = AgentsSettings.newBuilder().build();
try (AgentsClient client = AgentsClient.create(agentsSettings)) {
// Set the details of the Agent to create
Builder build = Agent.newBuilder();
build.setDefaultLanguageCode("en");
build.setDisplayName(displayName);
Agent agent = build.build();
// Make API request to create agent
Agent response = client.setAgent(agent);
System.out.println(response);
return response;
}
}
use of com.google.cloud.dialogflow.v2.Intent.Builder 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());
}
}
use of com.google.cloud.dialogflow.v2.Intent.Builder in project java-dialogflow-cx by googleapis.
the class UpdateIntent method updateIntent.
// DialogFlow API Update Intent sample.
public static void updateIntent(String projectId, String agentId, String intentId, String location, String displayName) throws IOException {
try (IntentsClient client = IntentsClient.create()) {
String intentPath = "projects/" + projectId + "/locations/" + location + "/agents/" + agentId + "/intents/" + intentId;
Builder intentBuilder = client.getIntent(intentPath).toBuilder();
intentBuilder.setDisplayName(displayName);
FieldMask fieldMask = FieldMask.newBuilder().addPaths("display_name").build();
Intent intent = intentBuilder.build();
UpdateIntentRequest request = UpdateIntentRequest.newBuilder().setIntent(intent).setLanguageCode("en").setUpdateMask(fieldMask).build();
// Make API request to update intent using fieldmask
Intent response = client.updateIntent(request);
System.out.println(response);
}
}
Aggregations