detectIntent method

Future<AIResponse> detectIntent(
  1. String query
)

Implementation

Future<AIResponse> detectIntent(String query) async {
  String queryParams = '{"resetContexts": ${this.resetContexts} }';

  if (payload.isNotEmpty) {
    queryParams =
        '{"resetContexts": ${this.resetContexts}, "payload": $payload}';
  }

  String body =
      '{"queryInput":{"text":{"text":"$query","language_code":"$language"}}, "queryParams": $queryParams}';

  var response = await authGoogle.post(_getUrl(),
      headers: {
        HttpHeaders.authorizationHeader: "Bearer ${authGoogle.getToken}"
      },
      body: body);

  return AIResponse(body: json.decode(response.body));
}