fromFile static method

Future<DialogFlowtter> fromFile({
  1. String path = kDefaultJsonPath,
  2. String? projectId,
  3. String sessionId = _kDefaultSessionId,
})

Creates a DialogFlowtter instance from the JSON in the given path

Since the file must be read from the disk, this operation is asynchronous and you need to await for the value to be ready

Detect intent

One of the core features of DialogFlow is to detect what a person is trying to say. You can do that by detecting an intent that you have defined in your DialogFlow console

  1. Create an instance of DialogFlowtter and set the sessionId that will be used to identify the current conversation of the user with DialogFlow.

It's highly recommended that you use a different sessionId for every conversation that the user establishes with the Assistant

  final DialogFlowtter dialogFlowtter = DialogFlowtter(
    credentials: credentials,
    sessionId: "YOUR_SESSION_ID_HERE",
  );
  1. Create a QueryInput where you can specify what data you want to send to DialogFlow.
  final QueryInput queryInput = QueryInput(
    text: TextInput(
      text: "Hi. How are you?",
      languageCode: "en",
    ),
  );
  1. Send your input to DialogFlow through the detectIntent function.
  DetectIntentResponse response = await dialogFlowtter.detectIntent(
    queryInput: queryInput,
  );

You can check the code for more info on what info you can send and receive

Change the project id

You can change the Project ID that DialogFlowtter will use to find your intents in DialogFlow.

  1. Create an instance of DialogFlowtter
  final DialogFlowtter dialogFlowtter = DialogFlowtter(
    credentials: credentials,
  );
  1. Change the projectId prop of the instance;
  dialogFlowtter.projectId = "deimos-apps-0905";

Implementation

static Future<DialogFlowtter> fromFile({
  String path = kDefaultJsonPath,
  String? projectId,
  String sessionId = _kDefaultSessionId,
}) async {
  DialogAuthCredentials creds = await DialogAuthCredentials.fromFile(path);
  return DialogFlowtter(
    credentials: creds,
    projectId: projectId,
    sessionId: sessionId,
  );
}