How do I get this Default response in Android?
我想获得与在android中执行此CURL请求相同的响应。是否可以使用API.AI SDK或其他方式做到这一点?
答案 0 :(得分:1)
您可以使用Dialogflow Android SDK。查看文档以进行集成和访问Dialogflow代理。
采取行动
final Result result = response.getResult();
Log.i(TAG, "Action: " + result.getAction());
发表演讲
final Result result = response.getResult();
final String speech = result.getFulfillment().getSpeech();
Log.i(TAG, "Speech: " + speech);
获取元数据
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());
}
获取参数
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()));
}
}