From acfccd65e221db23ea351751457254dd642cd18e Mon Sep 17 00:00:00 2001 From: Franklin Nunez <69214580+b-loved-dreamer@users.noreply.github.com> Date: Wed, 26 May 2021 12:55:24 -0700 Subject: [PATCH] samples: updated legacy field in detect intent samples (#575) --- .../com/example/dialogflow/DetectIntentWithLocation.java | 6 +++++- .../dialogflow/DetectIntentWithSentimentAnalysis.java | 6 +++++- .../dialogflow/DetectIntentWithTextToSpeechResponse.java | 6 +++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/dialogflow/snippets/src/main/java/com/example/dialogflow/DetectIntentWithLocation.java b/dialogflow/snippets/src/main/java/com/example/dialogflow/DetectIntentWithLocation.java index 9c6e943dcd4..6c825812577 100644 --- a/dialogflow/snippets/src/main/java/com/example/dialogflow/DetectIntentWithLocation.java +++ b/dialogflow/snippets/src/main/java/com/example/dialogflow/DetectIntentWithLocation.java @@ -73,7 +73,11 @@ public static Map detectIntentWithLocation( System.out.format( "Detected Intent: %s (confidence: %f)\n", queryResult.getIntent().getDisplayName(), queryResult.getIntentDetectionConfidence()); - System.out.format("Fulfillment Text: '%s'\n", queryResult.getFulfillmentText()); + System.out.format( + "Fulfillment Text: '%s'\n", + queryResult.getFulfillmentMessagesCount() > 0 + ? queryResult.getFulfillmentMessages(0).getText() + : "Triggered Default Fallback Intent"); queryResults.put(text, queryResult); } diff --git a/dialogflow/snippets/src/main/java/com/example/dialogflow/DetectIntentWithSentimentAnalysis.java b/dialogflow/snippets/src/main/java/com/example/dialogflow/DetectIntentWithSentimentAnalysis.java index 136590c9346..4a9133a3e50 100644 --- a/dialogflow/snippets/src/main/java/com/example/dialogflow/DetectIntentWithSentimentAnalysis.java +++ b/dialogflow/snippets/src/main/java/com/example/dialogflow/DetectIntentWithSentimentAnalysis.java @@ -80,7 +80,11 @@ public static Map detectIntentSentimentAnalysis( System.out.format( "Detected Intent: %s (confidence: %f)\n", queryResult.getIntent().getDisplayName(), queryResult.getIntentDetectionConfidence()); - System.out.format("Fulfillment Text: '%s'\n", queryResult.getFulfillmentText()); + System.out.format( + "Fulfillment Text: '%s'\n", + queryResult.getFulfillmentMessagesCount() > 0 + ? queryResult.getFulfillmentMessages(0).getText() + : "Triggered Default Fallback Intent"); System.out.format( "Sentiment Score: '%s'\n", queryResult.getSentimentAnalysisResult().getQueryTextSentiment().getScore()); diff --git a/dialogflow/snippets/src/main/java/com/example/dialogflow/DetectIntentWithTextToSpeechResponse.java b/dialogflow/snippets/src/main/java/com/example/dialogflow/DetectIntentWithTextToSpeechResponse.java index 3a40384c28d..fbe97131846 100644 --- a/dialogflow/snippets/src/main/java/com/example/dialogflow/DetectIntentWithTextToSpeechResponse.java +++ b/dialogflow/snippets/src/main/java/com/example/dialogflow/DetectIntentWithTextToSpeechResponse.java @@ -81,7 +81,11 @@ public static Map detectIntentWithTexttoSpeech( System.out.format( "Detected Intent: %s (confidence: %f)\n", queryResult.getIntent().getDisplayName(), queryResult.getIntentDetectionConfidence()); - System.out.format("Fulfillment Text: '%s'\n", queryResult.getFulfillmentText()); + System.out.format( + "Fulfillment Text: '%s'\n", + queryResult.getFulfillmentMessagesCount() > 0 + ? queryResult.getFulfillmentMessages(0).getText() + : "Triggered Default Fallback Intent"); queryResults.put(text, queryResult); }