app/com/google/strategic/demo/models/dialogflow/InteractionLayer.java
public static void createIntent(String displayName, String projectId,
                                    List<String> trainingPhrasesParts, List<String> messageTexts)
            throws Exception {
        // Instantiates a client
        try (IntentsClient intentsClient = IntentsClient.create()) {
            // Set the project agent name using the projectID (my-project-id)
            ProjectAgentName parent = ProjectAgentName.of(projectId);

            // Build the trainingPhrases from the trainingPhrasesParts
            List<TrainingPhrase> trainingPhrases = new ArrayList<>();
            for (String trainingPhrase : trainingPhrasesParts) {
                trainingPhrases.add(
                        TrainingPhrase.newBuilder().addParts(
                                Part.newBuilder().setText(trainingPhrase).build())
                                .build());
            }

            // Build the message texts for the agent's response
            Message message = Message.newBuilder()
                    .setText(
                            Text.newBuilder()
                                    .addAllText(messageTexts).build()
                    ).build();

            // Build the intent
            Intent intent = Intent.newBuilder()
                    .setDisplayName(displayName)
                    .addMessages(message)
                    .addAllTrainingPhrases(trainingPhrases)
                    .build();

            // Performs the create intent request
            Intent response = intentsClient.createIntent(parent, intent);
            System.out.format("Intent created: %s\n", response);
        }
    }
/**
     * Create an intent of the given intent type
     * @param displayName The display name of the intent.
     * @param projectId Project/Agent Id.
     * @param trainingPhrasesParts Training phrases.
     * @param messageTexts Message texts for the agent's response when the intent is detected.
     */
Create an intent of the given intent type
@param displayName The display name of the intent.
@param projectId Project/Agent Id.
@param trainingPhrasesParts Training phrases.
@param messageTexts Message texts for the agent's response when the intent is detected.
Create an intent of the given intent type @param displayName The display name of the intent . @param projectId Project / Agent Id . @param trainingPhrasesParts Training phrases . @param messageTexts Message texts for the agent ' s response when the intent is detected .
public static void createIntent(String displayName, String projectId,
                                    List<String> trainingPhrasesParts, List<String> messageTexts)
            throws Exception {
        try (IntentsClient intentsClient = IntentsClient.create()) {
            ProjectAgentName parent = ProjectAgentName.of(projectId);
            List<TrainingPhrase> trainingPhrases = new ArrayList<>();
            for (String trainingPhrase : trainingPhrasesParts) {
                trainingPhrases.add(
                        TrainingPhrase.newBuilder().addParts(
                                Part.newBuilder().setText(trainingPhrase).build())
                                .build());
            }
            Message message = Message.newBuilder()
                    .setText(
                            Text.newBuilder()
                                    .addAllText(messageTexts).build()
                    ).build();
            Intent intent = Intent.newBuilder()
                    .setDisplayName(displayName)
                    .addMessages(message)
                    .addAllTrainingPhrases(trainingPhrases)
                    .build();
            Intent response = intentsClient.createIntent(parent, intent);
            System.out.format("Intent created: %s\n", response);
        }
    }
public static void createIntent ( String displayName , String projectId , List < String > trainingPhrasesParts , List < String > messageTexts ) throws Exception { try ( IntentsClient intentsClient = IntentsClient . create ( ) ) { ProjectAgentName parent = ProjectAgentName . of ( projectId ) ; List < TrainingPhrase > trainingPhrases = new ArrayList < > ( ) ; for ( String trainingPhrase : trainingPhrasesParts ) { trainingPhrases . add ( TrainingPhrase . newBuilder ( ) . addParts ( Part . newBuilder ( ) . setText ( trainingPhrase ) . build ( ) ) . build ( ) ) ; } Message message = Message . newBuilder ( ) . setText ( Text . newBuilder ( ) . addAllText ( messageTexts ) . build ( ) ) . build ( ) ; Intent intent = Intent . newBuilder ( ) . setDisplayName ( displayName ) . addMessages ( message ) . addAllTrainingPhrases ( trainingPhrases ) . build ( ) ; Intent response = intentsClient . createIntent ( parent , intent ) ; System . out . format ( "Intent created: %s\n" , response ) ; } }
Create an intent of the given intent type
 @param displayName The display name of the intent.
Create an intent of the given intent type @param displayName The display name of the intent .
// Instantiates a client
 // Set the project agent name using the projectID (my-project-id)
 // Build the trainingPhrases from the trainingPhrasesParts
 // Build the message texts for the agent's response
 // Build the intent
 // Performs the create intent request
