use of ai.api.model.AIEvent in project dobby-android by InceptAi.
the class ApiAiClient method sendTextQuery.
public void sendTextQuery(@Nullable final String query, @Nullable final String event, final ResultListener listener) {
Preconditions.checkState(query != null || event != null);
threadpool.submit(new Runnable() {
@Override
public void run() {
final AIRequest aiRequest = new AIRequest();
if (query != null) {
aiRequest.setQuery(query);
}
if (event != null) {
aiRequest.setEvent(new AIEvent(event));
}
try {
DobbyLog.i("Submitting query: " + query);
final AIResponse response = aiDataService.request(aiRequest);
DobbyLog.i(" Response:" + GsonFactory.getGson().toJson(response.toString()));
processResult(response.getResult(), listener);
} catch (AIServiceException exception) {
DobbyLog.e("Api.ai Exception: " + exception);
}
}
});
}
Aggregations