detectIntent method

Future<DetectIntentResponse> detectIntent(
  1. String text,
  2. String lang
)

Processes a natural language query and returns structured, actionable data as a result.

var data = await dialogflow.detectIntent(text, 'en-US');
print(data.queryResult.fulfillmentText);

Implementation

Future<DetectIntentResponse> detectIntent(String text, String lang){

  final inputText = TextInput()
    ..text = text
    ..languageCode = lang;

  final queryInput = QueryInput()
  ..text = inputText;

  final request = DetectIntentRequest()
    ..queryInput = queryInput
    ..session = DialogflowAuth.session;

  return client.detectIntent(request);
}