[英]How to get Text response from DialogFlow agent in android?
How do I get this Default response in Android? 如何在Android中获得此默认响应?
I want to get the same response as I get doing this CURL request in android. 我想获得与在Android中执行此CURL请求相同的响应。 Is there a way to do this using API.AI SDK or otherwise?
是否可以使用API.AI SDK或其他方式执行此操作?
You can use Dialogflow Android SDK . 您可以使用Dialogflow Android SDK 。 Check the documentation for integration and accessing the Dialogflow agent.
检查文档以进行集成和访问Dialogflow代理。
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()));
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.