Search in sources :

Example 1 with AIEvent

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);
            }
        }
    });
}
Also used : AIResponse(ai.api.model.AIResponse) AIEvent(ai.api.model.AIEvent) AIRequest(ai.api.model.AIRequest) AIServiceException(ai.api.AIServiceException)

Aggregations

AIServiceException (ai.api.AIServiceException)1 AIEvent (ai.api.model.AIEvent)1 AIRequest (ai.api.model.AIRequest)1 AIResponse (ai.api.model.AIResponse)1