Dialogflow v2 apis for flutter applications.

Forked from https://github.com/VictorRancesCode/flutter_dialogflow

Dialogflow

Installation

  • Add this to your package's pubspec.yaml file:
dependencies:
  flutter_dialogflow_v2: ^0.1.0
  • You can install packages from the command line: with Flutter:
$ flutter packages get
  • Import it in your Dart code, you can use:
 import 'package:flutter_dialogflow_v2/flutter_dialogflow.dart';

Usage

  • Dialogflow register and create new Agent
  • Project Setup and Authentication
    • First of all, we need to create a Google Cloud Platform Project using Console Google Cloud
    • Create or select an existing GCP project.
    • From the GCP console, go to APIs and Services and click on credentials.
    • Click on Create credentials and choose Service account key.
    • Select your service account from the dropdown, choose JSON and click Create. This will download the JSON key to your computer. Save it securely.
    • We downloaded a JSON file with all our data.
  • In your project create folder assets(folder name recommended optional)
  • Move file json in your project in folder created
  • open file pubspec.yaml
flutter:
  uses-material-design: true
  assets:
    - assets/your_file_downloaded_google_cloud.json
  • Import dialogflow_v2
import 'package:flutter_dialogflow_v2/flutter_dialogflow_v2.dart';
  • Code examples
AuthGoogle authGoogle = await AuthGoogle(fileJson: 'assets/your_file.json').build();
Dialogflow dialogflow = Dialogflow(authGoogle: authGoogle, sessionId: '123456');
DetectIntentResponse response = await dialogflow.detectIntent(
  DetectIntentRequest(
    queryInput: QueryInput(
      text: TextInput(
        text: 'Hello from flutter!',
        languageCode: Language.english,
      ),
    ),
    queryParams: QueryParameters(
      resetContexts: true,
    ),
  ),
);
  • or if you simply want to simple query some text:
AuthGoogle authGoogle = await AuthGoogle(fileJson: 'assets/your_file.json').build();
Dialogflow dialogflow = Dialogflow(authGoogle: authGoogle, sessionId: '123456');
DetectIntentResponse response = await dialogflow.detectIntentFromText('Hello!');
  • get text response
response.queryResult.queryText;
  • or list of messages
response.queryResult.fulfillmentMessages;

Libraries

audio_encoding
audio_input_config
auth_google
basic_card
basic_card_button
card
card_button
carusel_select
context
detect_intent_request
detect_intent_response
dialogflow_v2
entity
entity_override_mode
event_input
flutter_dialogflow_v2
followup_intent_info
image
intent
item
language
lat_lng
list_select
map_messages
message
open_uri_action
parameter
part
payload
platform
query_input
query_parameters
query_result
quick_replies
select_item_info
session_entity_type
simple_response
simple_responses
status
suggestion
suggestions
text
text_input
training_phrase
type
webhook_state

Dart

VM

dart:ffi
Foreign Function Interface for interoperability with the C programming language. [...]

Web

dart:html
HTML elements and other resources for web-based applications that need to interact with the browser and the DOM (Document Object Model). [...]
dart:js
Low-level support for interoperating with JavaScript. [...]
dart:js_util
Utility methods to efficiently manipulate typed JSInterop objects in cases where the name to call is not known at runtime. You should only use these methods when the same effect cannot be achieved with @JS annotations. These methods would be extension methods on JSObject if Dart supported extension methods.