fromNetwork static method
Creates a DialogFlowtter instance with the JSON obtained from the given
url
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
- Create an instance of
DialogFlowtter
and set thesessionId
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",
);
- 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",
),
);
- 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.
- Create an instance of
DialogFlowtter
final DialogFlowtter dialogFlowtter = DialogFlowtter(
credentials: credentials,
);
- Change the
projectId
prop of the instance;
dialogFlowtter.projectId = "deimos-apps-0905";
Implementation
static Future<DialogFlowtter> fromNetwork(
String url, {
String? projectId,
String sessionId = _kDefaultSessionId,
}) async {
DialogAuthCredentials creds = await DialogAuthCredentials.fromNetwork(url);
return DialogFlowtter(
credentials: creds,
projectId: projectId,
sessionId: sessionId,
);
}