[英]How to integrate Dialogflow V2 into my Application?
In my android application, I'm integrating the Dialogflow V2 Agent.在我的 android 应用程序中,我正在集成 Dialogflow V2 代理。 There's no specific SDK for Android yet.目前还没有适用于 Android 的特定 SDK。 So I'm using the java client library from Dialogflow.所以我使用了 Dialogflow 的 java 客户端库。 followed the tutorial https://github.com/dialogflow/dialogflow-java-client-v2/issues/25 .遵循教程https://github.com/dialogflow/dialogflow-java-client-v2/issues/25 。
I've added the dependencies(dialogflow & oauth2) and created a service account in the google-cloud console.我已经添加了依赖项(dialogflow & oauth2)并在 google-cloud 控制台中创建了一个服务帐户。 Added the credential file into raw folder.将凭证文件添加到原始文件夹中。 followed the tutorial here https://github.com/dialogflow/dialogflow-java-client-v2/issues/25 .按照这里的教程https://github.com/dialogflow/dialogflow-java-client-v2/issues/25 。 Getting the error as得到错误为
java.lang.NoSuchMethodError: No static method decodeBase64(Ljava/lang/String;)[B in class Lorg/apache/commons/codec/binary/Base64; java.lang.NoSuchMethodError: No static method decodeBase64(Ljava/lang/String;)[B in class Lorg/apache/commons/codec/binary/Base64; or its super classes (declaration of 'org.apache.commons.codec.binary.Base64' appears in /system/framework/org.apache.http.legacy.boot.jar)或其超类('org.apache.commons.codec.binary.Base64' 的声明出现在 /system/framework/org.apache.http.legacy.boot.jar 中)
private void createDialogflow() {
try {
InputStream stream = getResources().openRawResource(R.raw.dialogflow_service_credentials);
GoogleCredentials credentials = GoogleCredentials.fromStream(stream);
String projectId = ((ServiceAccountCredentials) credentials).getProjectId();
SessionsSettings.Builder settingsBuilder = SessionsSettings.newBuilder();
SessionsSettings sessionsSettings = settingsBuilder.setCredentialsProvider(FixedCredentialsProvider.create(credentials)).build();
sessionsClient = SessionsClient.create(sessionsSettings);
String uuid = UUID.randomUUID().toString();
session = SessionName.of(projectId, uuid);
} catch (Exception e) {
e.printStackTrace();
}
}
private void sendMessage(String msg) {
// Java V2
setTypingMessage();
QueryInput queryInput = QueryInput.newBuilder().setText(TextInput.newBuilder().setText(msg).setLanguageCode("en-US")).build();
new RequestJavaV2Task(mContext, session, sessionsClient, queryInput).execute();
}
public void callbackV2(DetectIntentResponse response) {
removeTyingMessage();
if (response != null) {
// process aiResponse here
String botReply = response.getQueryResult().getFulfillmentText();
Log.d("botReply", "V2 Bot Reply: " + botReply);
setBotMessage(botReply);
} else {
Log.d("botReply", "Bot Reply: Null");
setBotMessage("There was some communication issue. Please Try again!");
}
}
Is there any clear documentations on how to integrate Dialogflow v2 into my android application.是否有关于如何将 Dialogflow v2 集成到我的 android 应用程序中的明确文档。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.