Skip to content
This repository has been archived by the owner on Sep 16, 2023. It is now read-only.

docs: add DetectIntent samples #500

Merged
merged 61 commits into from
Jul 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
27217aa
docs:add configure webhook to set form parameter as optional or requi…
aribray May 19, 2022
9ec52bf
docs: fix checkstyle
aribray May 19, 2022
47d91ad
fix checkstyle
aribray May 19, 2022
fec80c6
fix checkstyle
aribray May 19, 2022
7826893
fix multiline string
aribray May 19, 2022
b0ea884
fix checkstyle violations
aribray May 19, 2022
acd6659
fix checkstyle violations
aribray May 19, 2022
d9fb522
remove unused variable
aribray May 19, 2022
fedcc6b
fix checkstyle violations
aribray May 19, 2022
3b3d65f
🦉 Updates from OwlBot post-processor
gcf-owl-bot[bot] May 19, 2022
aec26af
fix checkstyle violations
aribray Jun 8, 2022
984a4bd
fix checkstyle violations
aribray Jun 8, 2022
4428653
fix checkstyle violations
aribray Jun 8, 2022
f6d9d1d
🦉 Updates from OwlBot post-processor
gcf-owl-bot[bot] Jun 8, 2022
006eda1
Merge remote-tracking branch 'origin/main' into aribray--webhook-samples
aribray Jun 14, 2022
7c35bf0
Merge branch 'aribray--webhook-samples' of github.com:aribray/java-di…
aribray Jun 14, 2022
fe9b212
remove unnecessary samples
aribray Jun 14, 2022
77ba085
add webhook configure session parameter sample and test
aribray Jun 14, 2022
16ab5b8
add webhook validate form parameter sample and test
aribray Jun 14, 2022
7bf63a0
fix checkstyle violations
aribray Jun 14, 2022
5176e43
fix checkstyle violations
aribray Jun 14, 2022
9d65836
🦉 Updates from OwlBot post-processor
gcf-owl-bot[bot] Jun 14, 2022
c6600ab
add detectintent with intent input sample and test
aribray Jun 29, 2022
20a4af4
docs: add detect intent samples and tests
aribray Jun 29, 2022
7bc2f49
Merge branch 'aribray--detect-intent-samples' of github.com:aribray/j…
aribray Jun 29, 2022
7d4dad9
add detectintent with audio input sample and test
aribray Jun 29, 2022
c4654a1
fix checkstyle violations
aribray Jun 29, 2022
6e95970
add detectintent with event input sample and test
aribray Jun 29, 2022
0227237
add detectintent with sentiment analysis sample and test
aribray Jun 29, 2022
6745538
add detectintent with webhook disabled sample and test
aribray Jun 29, 2022
711b936
add detectintentstreamingpartialresponse sample and test
aribray Jun 30, 2022
d3d9153
add detectintentsynthesizettsoutput sample and test
aribray Jun 30, 2022
8b2db12
fix checkstyle violations
aribray Jun 30, 2022
0eb6f87
rename detectintent with text input sample and test
aribray Jun 30, 2022
dba9630
🦉 Updates from OwlBot post-processor
gcf-owl-bot[bot] Jun 30, 2022
45a161d
change the name back
aribray Jun 30, 2022
2fb85f5
Merge branch 'aribray--detect-intent-samples' of github.com:aribray/j…
aribray Jun 30, 2022
44e137a
🦉 Updates from OwlBot post-processor
gcf-owl-bot[bot] Jun 30, 2022
121eabe
fix comments
aribray Jun 30, 2022
38656f0
Merge branch 'aribray--detect-intent-samples' of github.com:aribray/j…
aribray Jun 30, 2022
7535047
remove old webhook samples
aribray Jun 30, 2022
690fb44
🦉 Updates from OwlBot post-processor
gcf-owl-bot[bot] Jun 30, 2022
de4a43c
v3beta1 to v3
aribray Jun 30, 2022
a0713d8
Merge branch 'aribray--detect-intent-samples' of github.com:aribray/j…
aribray Jun 30, 2022
085589f
v3beta1 to v3
aribray Jun 30, 2022
99e49e8
add flag to kokoro build script
aribray Jun 30, 2022
5698e11
fix test assertion
aribray Jun 30, 2022
ae7c54b
🦉 Updates from OwlBot post-processor
gcf-owl-bot[bot] Jun 30, 2022
3e12cc1
remove flag
aribray Jun 30, 2022
4cce0dd
Merge branch 'aribray--detect-intent-samples' of github.com:aribray/j…
aribray Jun 30, 2022
73ab951
hardcode parameters
aribray Jul 7, 2022
7f03607
move sessionID comments
aribray Jul 7, 2022
a9da7a4
add main and hardcode variables
aribray Jul 7, 2022
613028c
add session path comments and path format
aribray Jul 7, 2022
5bb7eda
checkstyle
aribray Jul 7, 2022
cd8d6c6
checkstyle
aribray Jul 7, 2022
1eeeec7
🦉 Updates from OwlBot post-processor
gcf-owl-bot[bot] Jul 7, 2022
2d8a47e
Merge branch 'main' into aribray--detect-intent-samples
aribray Jul 7, 2022
f146dce
Merge remote-tracking branch 'origin/main' into aribray--detect-inten…
aribray Jul 12, 2022
d4569f8
fix list construction
aribray Jul 12, 2022
b68e81c
import ArrayList
aribray Jul 12, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,14 @@ Samples are in the [`samples/`](https://github.com/googleapis/java-dialogflow-cx
| Create Simple Page | [source code](https://github.com/googleapis/java-dialogflow-cx/blob/main/samples/snippets/src/main/java/dialogflow/cx/CreateSimplePage.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-dialogflow-cx&page=editor&open_in_editor=samples/snippets/src/main/java/dialogflow/cx/CreateSimplePage.java) |
| Delete Page | [source code](https://github.com/googleapis/java-dialogflow-cx/blob/main/samples/snippets/src/main/java/dialogflow/cx/DeletePage.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-dialogflow-cx&page=editor&open_in_editor=samples/snippets/src/main/java/dialogflow/cx/DeletePage.java) |
| Detect Intent | [source code](https://github.com/googleapis/java-dialogflow-cx/blob/main/samples/snippets/src/main/java/dialogflow/cx/DetectIntent.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-dialogflow-cx&page=editor&open_in_editor=samples/snippets/src/main/java/dialogflow/cx/DetectIntent.java) |
| Detect Intent Audio Input | [source code](https://github.com/googleapis/java-dialogflow-cx/blob/main/samples/snippets/src/main/java/dialogflow/cx/DetectIntentAudioInput.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-dialogflow-cx&page=editor&open_in_editor=samples/snippets/src/main/java/dialogflow/cx/DetectIntentAudioInput.java) |
| Detect Intent Disable Webhook | [source code](https://github.com/googleapis/java-dialogflow-cx/blob/main/samples/snippets/src/main/java/dialogflow/cx/DetectIntentDisableWebhook.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-dialogflow-cx&page=editor&open_in_editor=samples/snippets/src/main/java/dialogflow/cx/DetectIntentDisableWebhook.java) |
| Detect Intent Event Input | [source code](https://github.com/googleapis/java-dialogflow-cx/blob/main/samples/snippets/src/main/java/dialogflow/cx/DetectIntentEventInput.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-dialogflow-cx&page=editor&open_in_editor=samples/snippets/src/main/java/dialogflow/cx/DetectIntentEventInput.java) |
| Detect Intent Intent Input | [source code](https://github.com/googleapis/java-dialogflow-cx/blob/main/samples/snippets/src/main/java/dialogflow/cx/DetectIntentIntentInput.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-dialogflow-cx&page=editor&open_in_editor=samples/snippets/src/main/java/dialogflow/cx/DetectIntentIntentInput.java) |
| Detect Intent Sentiment Analysis | [source code](https://github.com/googleapis/java-dialogflow-cx/blob/main/samples/snippets/src/main/java/dialogflow/cx/DetectIntentSentimentAnalysis.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-dialogflow-cx&page=editor&open_in_editor=samples/snippets/src/main/java/dialogflow/cx/DetectIntentSentimentAnalysis.java) |
| Detect Intent Stream | [source code](https://github.com/googleapis/java-dialogflow-cx/blob/main/samples/snippets/src/main/java/dialogflow/cx/DetectIntentStream.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-dialogflow-cx&page=editor&open_in_editor=samples/snippets/src/main/java/dialogflow/cx/DetectIntentStream.java) |
| Detect Intent Streaming Partial Response | [source code](https://github.com/googleapis/java-dialogflow-cx/blob/main/samples/snippets/src/main/java/dialogflow/cx/DetectIntentStreamingPartialResponse.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-dialogflow-cx&page=editor&open_in_editor=samples/snippets/src/main/java/dialogflow/cx/DetectIntentStreamingPartialResponse.java) |
| Detect Intent Synthesize Text To Speech Output | [source code](https://github.com/googleapis/java-dialogflow-cx/blob/main/samples/snippets/src/main/java/dialogflow/cx/DetectIntentSynthesizeTextToSpeechOutput.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-dialogflow-cx&page=editor&open_in_editor=samples/snippets/src/main/java/dialogflow/cx/DetectIntentSynthesizeTextToSpeechOutput.java) |
| Export Agent | [source code](https://github.com/googleapis/java-dialogflow-cx/blob/main/samples/snippets/src/main/java/dialogflow/cx/ExportAgent.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-dialogflow-cx&page=editor&open_in_editor=samples/snippets/src/main/java/dialogflow/cx/ExportAgent.java) |
| List Pages | [source code](https://github.com/googleapis/java-dialogflow-cx/blob/main/samples/snippets/src/main/java/dialogflow/cx/ListPages.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-dialogflow-cx&page=editor&open_in_editor=samples/snippets/src/main/java/dialogflow/cx/ListPages.java) |
| List Test Case Results | [source code](https://github.com/googleapis/java-dialogflow-cx/blob/main/samples/snippets/src/main/java/dialogflow/cx/ListTestCaseResults.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-dialogflow-cx&page=editor&open_in_editor=samples/snippets/src/main/java/dialogflow/cx/ListTestCaseResults.java) |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
/*
* Copyright 2022 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package dialogflow.cx;

// [START dialogflow_cx_v3_detect_intent_audio_input]

import com.google.api.gax.rpc.ApiException;
import com.google.cloud.dialogflow.cx.v3.AudioEncoding;
import com.google.cloud.dialogflow.cx.v3.AudioInput;
import com.google.cloud.dialogflow.cx.v3.DetectIntentRequest;
import com.google.cloud.dialogflow.cx.v3.DetectIntentResponse;
import com.google.cloud.dialogflow.cx.v3.InputAudioConfig;
import com.google.cloud.dialogflow.cx.v3.QueryInput;
import com.google.cloud.dialogflow.cx.v3.QueryResult;
import com.google.cloud.dialogflow.cx.v3.SessionName;
import com.google.cloud.dialogflow.cx.v3.SessionsClient;
import com.google.cloud.dialogflow.cx.v3.SessionsSettings;
import com.google.protobuf.ByteString;
import java.io.FileInputStream;
import java.io.IOException;

public class DetectIntentAudioInput {

// DialogFlow API Detect Intent sample with Audio input.
public static void main(String[] args) throws IOException, ApiException {
/** TODO (developer): replace these values with your own values */
String projectId = "my-project-id";
String locationId = "global";
String agentId = "my-agent-id";
aribray marked this conversation as resolved.
Show resolved Hide resolved
String audioFileName = "resources/book_a_room.wav";
int sampleRateHertz = 16000;
/*
* A session ID is a string of at most 36 bytes in size.
* Your system is responsible for generating unique session IDs.
* They can be random numbers, hashed end-user identifiers,
* or any other values that are convenient for you to generate.
*/
String sessionId = "my-UUID";
String languageCode = "en";

detectIntent(
projectId, locationId, agentId, audioFileName, sampleRateHertz, sessionId, languageCode);
}

public static void detectIntent(
String projectId,
String locationId,
String agentId,
String audioFileName,
int sampleRateHertz,
String sessionId,
String languageCode)
throws IOException, ApiException {

SessionsSettings.Builder sessionsSettingsBuilder = SessionsSettings.newBuilder();
if (locationId.equals("global")) {
sessionsSettingsBuilder.setEndpoint("dialogflow.googleapis.com:443");
} else {
sessionsSettingsBuilder.setEndpoint(locationId + "-dialogflow.googleapis.com:443");
}
SessionsSettings sessionsSettings = sessionsSettingsBuilder.build();

// Instantiates a client by setting the session name.
// Format:`projects/<ProjectID>/locations/<LocationID>/agents/<AgentID>/sessions/<SessionID>`
try (SessionsClient sessionsClient = SessionsClient.create(sessionsSettings)) {
SessionName session =
SessionName.ofProjectLocationAgentSessionName(projectId, locationId, agentId, sessionId);

// TODO : Uncomment if you want to print session path
// System.out.println("Session Path: " + session.toString());
InputAudioConfig inputAudioConfig =
InputAudioConfig.newBuilder()
.setAudioEncoding(AudioEncoding.AUDIO_ENCODING_LINEAR_16)
.setSampleRateHertz(sampleRateHertz)
.build();

try (FileInputStream audioStream = new FileInputStream(audioFileName)) {
// Subsequent requests must **only** contain the audio data.
// Following messages: audio chunks. We just read the file in fixed-size chunks. In reality
// you would split the user input by time.
byte[] buffer = new byte[4096];
int bytes = audioStream.read(buffer);
AudioInput audioInput =
AudioInput.newBuilder()
.setAudio(ByteString.copyFrom(buffer, 0, bytes))
.setConfig(inputAudioConfig)
.build();
QueryInput queryInput =
QueryInput.newBuilder()
.setAudio(audioInput)
.setLanguageCode("en-US") // languageCode = "en-US"
.build();

DetectIntentRequest request =
DetectIntentRequest.newBuilder()
.setSession(session.toString())
.setQueryInput(queryInput)
.build();

// Performs the detect intent request.
DetectIntentResponse response = sessionsClient.detectIntent(request);

// Display the query result.
QueryResult queryResult = response.getQueryResult();

System.out.println("====================");
System.out.format(
"Detected Intent: %s (confidence: %f)\n",
queryResult.getTranscript(), queryResult.getIntentDetectionConfidence());
}
}
}
}
// [END dialogflow_cx_v3_detect_intent_audio_input]
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
/*
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package dialogflow.cx;

// [START dialogflow_cx_v3_detect_intent_disable_webhook]

import com.google.api.gax.rpc.ApiException;
import com.google.cloud.dialogflow.cx.v3.DetectIntentRequest;
import com.google.cloud.dialogflow.cx.v3.DetectIntentResponse;
import com.google.cloud.dialogflow.cx.v3.QueryInput;
import com.google.cloud.dialogflow.cx.v3.QueryParameters;
import com.google.cloud.dialogflow.cx.v3.QueryResult;
import com.google.cloud.dialogflow.cx.v3.SessionName;
import com.google.cloud.dialogflow.cx.v3.SessionsClient;
import com.google.cloud.dialogflow.cx.v3.SessionsSettings;
import com.google.cloud.dialogflow.cx.v3.TextInput;
import com.google.common.collect.Maps;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public class DetectIntentDisableWebhook {
aribray marked this conversation as resolved.
Show resolved Hide resolved

public static void main(String[] args) throws IOException, ApiException {
String projectId = "my-project-id";
String locationId = "global";
String agentId = "my-agent-id";
String sessionId = "my-UUID";
List<String> texts = new ArrayList<>(List.of("my-list", "of-texts"));
String languageCode = "en";

detectIntent(projectId, locationId, agentId, sessionId, texts, languageCode);
}

// DialogFlow API Detect Intent sample with webhook disabled.
public static Map<String, QueryResult> detectIntent(
String projectId,
String locationId,
String agentId,
String sessionId,
List<String> texts,
String languageCode)
throws IOException, ApiException {
SessionsSettings.Builder sessionsSettingsBuilder = SessionsSettings.newBuilder();
if (locationId.equals("global")) {
sessionsSettingsBuilder.setEndpoint("dialogflow.googleapis.com:443");
} else {
sessionsSettingsBuilder.setEndpoint(locationId + "-dialogflow.googleapis.com:443");
}
SessionsSettings sessionsSettings = sessionsSettingsBuilder.build();

Map<String, QueryResult> queryResults = Maps.newHashMap();

// Instantiates a client by setting the session name.
// Format:`projects/<ProjectID>/locations/<LocationID>/agents/<AgentID>/sessions/<SessionID>`
try (SessionsClient sessionsClient = SessionsClient.create(sessionsSettings)) {
SessionName session =
SessionName.ofProjectLocationAgentSessionName(projectId, locationId, agentId, sessionId);

// TODO : Uncomment if you want to print session path
// System.out.println("Session Path: " + session.toString());

// Detect intents for each text input.
for (String text : texts) {
// Set the text (hello) for the query.
TextInput.Builder textInput = TextInput.newBuilder().setText(text);

// Build the query with the TextInput and language code (en-US).
QueryInput queryInput =
QueryInput.newBuilder().setText(textInput).setLanguageCode(languageCode).build();

// Build the query parameters and setDisableWebhook to true.
QueryParameters queryParameters =
QueryParameters.newBuilder().setDisableWebhook(true).build();

// Build the DetectIntentRequest with the SessionName, QueryInput, and QueryParameters.
DetectIntentRequest request =
DetectIntentRequest.newBuilder()
.setSession(session.toString())
.setQueryInput(queryInput)
.setQueryParams(queryParameters)
.build();
System.out.println(request.toString());

// Performs the detect intent request.
DetectIntentResponse response = sessionsClient.detectIntent(request);

// Display the query result.
QueryResult queryResult = response.getQueryResult();

// TODO : Uncomment if you want to print queryResult
// System.out.println("====================");
// System.out.format("Query Text: '%s'\n", queryResult.getText());
// System.out.format(
// "Detected Intent: %s (confidence: %f)\n",
// queryResult.getIntent().getDisplayName(),
// queryResult.getIntentDetectionConfidence());

queryResults.put(text, queryResult);
}
}
return queryResults;
}
}
// [END dialogflow_cx_v3_detect_intent_disable_webhook]
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
/*
* Copyright 2022 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package dialogflow.cx;

// [START dialogflow_cx_v3_detect_intent_event_input]

import com.google.api.gax.rpc.ApiException;
import com.google.cloud.dialogflow.cx.v3.DetectIntentRequest;
import com.google.cloud.dialogflow.cx.v3.DetectIntentResponse;
import com.google.cloud.dialogflow.cx.v3.EventInput;
import com.google.cloud.dialogflow.cx.v3.QueryInput;
import com.google.cloud.dialogflow.cx.v3.QueryResult;
import com.google.cloud.dialogflow.cx.v3.SessionName;
import com.google.cloud.dialogflow.cx.v3.SessionsClient;
import com.google.cloud.dialogflow.cx.v3.SessionsSettings;
import java.io.IOException;

public class DetectIntentEventInput {

// DialogFlow API Detect Intent sample with Event input.
public static void main(String[] args) throws IOException, ApiException {
String projectId = "my-project-id";
String locationId = "global";
String agentId = "my-agent-id";
String sessionId = "my-UUID";
String event = "my-event-id";
String languageCode = "en";

detectIntent(projectId, locationId, agentId, sessionId, event, languageCode);
}

public static void detectIntent(
String projectId,
String locationId,
String agentId,
String sessionId,
String event,
String languageCode)
throws IOException, ApiException {

SessionsSettings.Builder sessionsSettingsBuilder = SessionsSettings.newBuilder();
if (locationId.equals("global")) {
sessionsSettingsBuilder.setEndpoint("dialogflow.googleapis.com:443");
} else {
sessionsSettingsBuilder.setEndpoint(locationId + "-dialogflow.googleapis.com:443");
}
SessionsSettings sessionsSettings = sessionsSettingsBuilder.build();

// Instantiates a client by setting the session name.
// Format:`projects/<ProjectID>/locations/<LocationID>/agents/<AgentID>/sessions/<SessionID>`
try (SessionsClient sessionsClient = SessionsClient.create(sessionsSettings)) {
SessionName session =
SessionName.ofProjectLocationAgentSessionName(projectId, locationId, agentId, sessionId);

// TODO : Uncomment if you want to print session path
// System.out.println("Session Path: " + session.toString());

EventInput.Builder eventInput = EventInput.newBuilder().setEvent(event);

// Build the query with the EventInput and language code (en-US).
QueryInput queryInput =
QueryInput.newBuilder().setEvent(eventInput).setLanguageCode(languageCode).build();

// Build the DetectIntentRequest with the SessionName and QueryInput.
DetectIntentRequest request =
DetectIntentRequest.newBuilder()
.setSession(session.toString())
.setQueryInput(queryInput)
.build();

// Performs the detect intent request.
DetectIntentResponse response = sessionsClient.detectIntent(request);

// Display the query result.
QueryResult queryResult = response.getQueryResult();

// TODO : Uncomment if you want to print queryResult
System.out.println("====================");
System.out.format("Triggering Event: %s \n", queryResult.getTriggerEvent());
}
}
}

// [END dialogflow_cx_v3_detect_intent_event_input]
Loading