flutter_dialogflow 0.1.3

  • Readme
  • Changelog
  • Example
  • Installing
  • 89

Dialogflow v1 & v2 for Flutter apps. #

Dialogflow

❤️ Star ❤️ the repo to support the project. Thanks! #

A new Flutter package.

Awesome Tutorials #

Thanks for the tutorials!

Installation #

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

Usage #

Dialogflow v1 #

  • Dialogflow register and create new Agent
  • Copy Api key (Token)
  • Code
  Dialogflow dialogflow = Dialogflow(token: "Your Token");
  AIResponse response = await dialogflow.sendQuery("Your Query");
  • Example
  void Response(query) async {
    Dialogflow dialogflow = Dialogflow(token: "10178f9cb6cf12321asdf4aae75c87cd");
    AIResponse response = await dialogflow.sendQuery(query);
    print(response.getMessageResponse());
  }

Dialogflow v2 #

  • Dialogflow](https://dialogflow.com/) 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/dialogflow_v2.dart';
  • Code
  AuthGoogle authGoogle = await AuthGoogle(fileJson: "Asset Your File Json").build();
  // Select Language.ENGLISH or Language.SPANISH or others...
  Dialogflow dialogflow =Dialogflow(authGoogle: authGoogle,language: Language.ENGLISH); 
  AIResponse response = await dialogflow.detectIntent("Your Query");
  • Example
  AuthGoogle authGoogle = await AuthGoogle(fileJson: "assets/your_file_downloaded_google_cloud.json").build();
  Dialogflow dialogflow = Dialogflow(authGoogle: authGoogle,language: Language.ENGLISH);
  AIResponse response = await dialogflow.detectIntent("Hi!!!");
  print(response.getMessage())
  • Or Get List Message type Card
Call function response.getListMessage() 
response List<dynamic>
example 
new CardDialogflow(response.getListMessage()[0]).title
Convert first item in CardDialogflow for worked easy
CardDialogflow have
- title
- subtitle
- imageUri
- List buttonss
    - each button have text and postback

Demo

Dialogflow For Flutter Web #

Visit the repository: Flutter Dialogflow Web 🚀

[0.1.3] - TODO: 27-03-2019. #

  • Upgrade dependencies and added example

[0.1.2] - TODO: 27-03-2019. #

  • Fix delete dartdoc

[0.1.1] - TODO: 26-11-2018. #

  • Fix 'AUTHORIZATION' is deprecated and added dartdoc

[0.1.0] - TODO: 25-11-2018. #

  • Support Dart 2.0 and added Support for Dialogflow V2

[0.0.1] - TODO: 27-05-2018. #

  • The flutter_dialogflow makes it easy to integrate dialogflow

example/lib/main.dart

import 'package:example/dialogflow_v1.dart';
import 'package:example/dialogflow_v2.dart';
import 'package:flutter/material.dart';

import 'google_assistant.dart';

void main() => runApp(new MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      title: 'Example Dialogflow Flutter',
      theme: new ThemeData(
        primarySwatch: Colors.deepOrange,
      ),
      home: new MyHomePage(title: 'Flutter Demo Dialogflow'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _MyHomePageState createState() => new _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: new AppBar(
        title: new Text(widget.title),
      ),
      body: new Column(children: <Widget>[
        new Container(
          margin: EdgeInsets.all(10.0),
          child: new RaisedButton(
            onPressed: () {
              Navigator.push(
                context,
                MaterialPageRoute(builder: (context) => PageDialogflowV1()),
              );
            },
            child: Text("Dialogflow v1"),
          ),
        ),
        new Container(
          margin: EdgeInsets.all(10.0),
          child: new RaisedButton(
            onPressed: () {
              Navigator.push(
                context,
                MaterialPageRoute(builder: (context) => HomePageDialogflowV2()),
              );
            },
            child: Text("Dialogflow v2"),
          ),
        ),
        new Container(
          margin: EdgeInsets.all(10.0),
          child: new RaisedButton(
            onPressed: () {
              Navigator.push(
                context,
                MaterialPageRoute(builder: (context) => GoogleAssistant()),
              );
            },
            child: Text("GoogleAssistant"),
          ),
        )
      ]),
    );
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  flutter_dialogflow: ^0.1.3

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:flutter_dialogflow/flutter_dialogflow.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
91
Health:
Code health derived from static analysis. [more]
84
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
90
Overall:
Weighted score of the above. [more]
89
Learn more about scoring.

We analyzed this package on Jul 14, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.15
  • Flutter: 1.17.5

Analysis suggestions

Package not compatible with SDK dart

Because:

  • flutter_dialogflow that is a package requiring null.

Package not compatible with runtime flutter-web on Web

Because:

  • package:flutter_dialogflow/flutter_dialogflow.dart that imports:
  • dart:io

Health suggestions

Fix lib/utils/language.dart. (-13.96 points)

Analysis of lib/utils/language.dart reported 30 hints, including:

line 5 col 17: Name non-constant identifiers using lowerCamelCase.

line 10 col 17: Name non-constant identifiers using lowerCamelCase.

line 15 col 17: Name non-constant identifiers using lowerCamelCase.

line 20 col 17: Name non-constant identifiers using lowerCamelCase.

line 25 col 17: Name non-constant identifiers using lowerCamelCase.

Fix lib/v2/auth_google.dart. (-1.49 points)

Analysis of lib/v2/auth_google.dart reported 3 hints:

line 20 col 3: The class 'Future' wasn't exported from 'dart:core' until version 2.1, but this code is required to be able to run on earlier versions.

line 25 col 3: The class 'Future' wasn't exported from 'dart:core' until version 2.1, but this code is required to be able to run on earlier versions.

line 50 col 3: The class 'Future' wasn't exported from 'dart:core' until version 2.1, but this code is required to be able to run on earlier versions.

Fix lib/v2/dialogflow_v2.dart. (-0.50 points)

Analysis of lib/v2/dialogflow_v2.dart reported 1 hint:

line 117 col 3: The class 'Future' wasn't exported from 'dart:core' until version 2.1, but this code is required to be able to run on earlier versions.

Fix additional 3 files with analysis or formatting issues.

Additional issues in the following files:

  • lib/dialogflow_v2.dart (Run flutter format to format lib/dialogflow_v2.dart.)
  • lib/flutter_dialogflow.dart (Run flutter format to format lib/flutter_dialogflow.dart.)
  • lib/v2/message.dart (Run flutter format to format lib/v2/message.dart.)

Maintenance issues and suggestions

Make sure dartdoc successfully runs on your package's source files. (-10 points)

exitCode: 255 stdout: Documenting flutter_dialogflow... Initialized dartdoc with 630 libraries in 96.9 seconds Generating docs for library auth_google from package:flutter_dialogflow/v2/auth_google.dart... Generating docs for library dialogflow_v2 from package:flutter_dialogflow/v2/dialogflow_v2.dart... Generating docs for library flutter_dialogflow from package:flutter_dialogflow/dialogflow_v2.dart... Generating docs for library flutter_dialogflow from package:flutter_dialogflow/flutter_dialogflow.dart... Generating docs for library language from package:flutter_dialogflow/utils/language.dart... Generating docs for library message from package:flutter_dialogflow/v2/message.dart... Validating docs... Documented 6 public libraries in 16.7 seconds stderr: warning: flutter_dialogflow has no library level documentation comments, from flutter_dialogflow: (file:///tmp/pub-dartlang-dartdocZVLSET/pkg/lib/dialogflow_v2.dart:1:9) warning: flutter_dialogflow has no library level documentation comments, from flutter_dialogflow: (file:///tmp/pub-dartlang-dartdocZVLSET/pkg/lib/flutter_dialogflow.dart:1:9) error: failed to write file at: flutter_dialogflow/flutter_dialogflow-library.html for symbol flutter_dialogflow: (file:///tmp/pub-dartlang-dartdocZVLSET/pkg/lib/flutter_dialogflow.dart:1:9) conflicting with file already generated by flutter_dialogflow: (file:///tmp/pub-dartlang-dartdocZVLSET/pkg/lib/dialogflow_v2.dart:1:9) Dartdoc generates a path and filename to write to for each symbol. flutter_dialogflow conflicts with another symbol in the generated path, and therefore can not be written out. Changing the name, library name, or class name (if appropriate) of one of the conflicting items can resolve the conflict. Alternatively, use the @nodoc tag in one symbol's documentation comments to hide it. found 2 warnings and 1 error Unhandled exception: dartdoc encountered 1 errors while processing. #0 Dartdoc.generateDocs (package:dartdoc/dartdoc.dart:225:9)

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.20.1 <3.0.0
flutter 0.0.0
googleapis_auth ^0.2.6 0.2.12
http ^0.12.0+2 0.12.1
Transitive dependencies
charcode 1.1.3
collection 1.14.12 1.14.13
convert 2.1.1
crypto 2.1.5
http_parser 3.1.4
meta 1.1.8 1.2.2
path 1.7.0
pedantic 1.9.0 1.9.2
sky_engine 0.0.99
source_span 1.7.0
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6 1.2.0
vector_math 2.0.8 2.1.0-nullsafety
Dev dependencies
flutter_test
test any