Reputation: 940
How do I get this Default response in Android?
I want to get the same response as I get doing this CURL request in android. Is there a way to do this using API.AI SDK or otherwise?
Upvotes: 0
Views: 753
Reputation: 5266
You can use Dialogflow Android SDK. Check the documentation for integration and accessing the Dialogflow agent.
Get action
final Result result = response.getResult();
Log.i(TAG, "Action: " + result.getAction());
Get speech
final Result result = response.getResult();
final String speech = result.getFulfillment().getSpeech();
Log.i(TAG, "Speech: " + speech);
Get metadata
final Result result = response.getResult();
final Metadata metadata = result.getMetadata();
if (metadata != null) {
Log.i(TAG, "Intent id: " + metadata.getIntentId());
Log.i(TAG, "Intent name: " + metadata.getIntentName());
}
Get parameters
final Result result = response.getResult();
final HashMap<String, JsonElement> params = result.getParameters();
if (params != null && !params.isEmpty()) {
Log.i(TAG, "Parameters: ");
for (final Map.Entry<String, JsonElement> entry : params.entrySet()) {
Log.i(TAG, String.format("%s: %s", entry.getKey(), entry.getValue().toString()));
}
}
Upvotes: 1