• Stars
    star
    412
  • Rank 104,443 (Top 3 %)
  • Language
    TypeScript
  • License
    Apache License 2.0
  • Created over 9 years ago
  • Updated over 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

JavaScript Web SDK for Dialogflow

DEPRECATED

Deprecated
This Dialogflow client library and Dialogflow API V1 have been deprecated and will be shut down on October 23th, 2019. Please migrate to Dialogflow API V2.

You can use this library as common pre-built .js (choose there).

Or you can install it with nodejs and that import as es6 (or .ts) module. See below.

npm install [email protected]

Usage

.textRequest

const client = new ApiAi.ApiAiClient({accessToken: 'YOUR_ACCESS_TOKEN'});
const promise = client.textRequest(longTextRequest);

promise
    .then(handleResponse)
    .catch(handleError);

function handleResponse(serverResponse) {
        console.log(serverResponse);
}
function handleError(serverError) {
        console.log(serverError);
}

.eventRequest

const promise = client.eventRequest("EVENT_NAME", options);

TypeScript and ES6

This SDK written with Typescript and all it's sources are available in this package. So basically if you are using something like webpack or browserify with ES6 imports and so on, you can just install this SDK with $ npm install api-ai-javascript --save-dev command and then import original sources with something like:

import {ApiAiClient} from "api-ai-javascript";

const client = new ApiAiClient({accessToken: 'YOUR_ACCESS_TOKEN'})

.textRequest('Hello!')
    .then((response) => {/* do something */})
    .catch((error) => {/* do something here too */})

Note: If you are going to build es5 version of your bundle with ApiAiClient inside, please add some typings for promises (e.g. @types/es6-promise)

You also can import and use all defined interfaces and ApiAiConstants:

import {IRequestOptions, IServerResponse, ApiAiConstants} from "api-ai-javascript/ApiAiClient"
const lang = ApiAiConstants.AVAILABLE_LANGUAGES.EN;

You can find full list of interfaces here

Development

  • Checkout from this repository, do not forget to switch to "v2" branch
  • run $ npm install
  • run $ webpack -w or just $ npm start (as an option for non globally installed dev-server - $ ./node_modules/.bin/webpack-dev-server)
  • develop! (webpack will automatically compile SDK to ./target/ApiAi.js file on each change, just include it into some test HTML file (./demo/index.html will probably do the job) and test it).

Building

$ npm run-script build command will build everything

Testing

$ npm test

Changelog

2.0.0-beta.21

  • tts and asr support removed (discontinued on API.AI side)

2.0.0-beta.19

  • minor typings changes

2.0.0-beta.18

  • some minor typings changes

2.0.0-beta.17

  • dependencies updated
  • webrtc typings removed (now part of typescript default lib)

2.0.0-beta.16

  • some linting (ionic2 compatibility issues)

2.0.0-beta.15

  • minor fixes, minor readme updates
  • exported constants

2.0.0-beta.14

  • minor fixes
  • GainNode removed (for now) as non-working in current setup

2.0.0-beta.13

  • IStreamClient is aligned with StreamClient needs, thanks to @muuki88 (#26)
  • Callbacks in IStremClientOptions are now typed properly
  • Added IStreamClient.getGain(): GainNode (#25) to allow set up gain of listener
  • Fixed UTF8 requests, thanks to @elaval (#24)

2.0.0-beta.12

  • Possibility to import ApiAiClient separately from ApiAiStreamClient
  • Typescript project demo setup added

2.0.0-beta.8

Breaking changes:

  • Main class renamed from Client to ApiAiClient
  • StreamClient renamed (in exports at least) to ApiAiStreamClient
  • StreamClient class is no longer available inside main ApiAiClient class and now should be passed directly in ApiAiClient constructor: const client = new ApiAiClient("ACCESS_TOKEN", {streamClientClass: ApiAiStreamClient}).That was made to allow building your applications without streamclient at all (streamclient now takes about 70% of whole library). And also there will be other implementation of streamClient in the future

Non-breaking changes:

  • Demo updated

How to make contributions?

Please read and follow the steps in the CONTRIBUTING.md.

License

See LICENSE.

Terms

Your use of this sample is subject to, and by using or downloading the sample files you agree to comply with, the Google APIs Terms of Service.

This is not an official Google product.

More Repositories

1

dialogflow-nodejs-client

Node.js SDK for Dialogflow
JavaScript
658
star
2

dialogflow-fulfillment-nodejs

Dialogflow agent fulfillment library supporting v1&v2, 8 platforms, and text, card, image, suggestion, custom responses
JavaScript
599
star
3

dialogflow-android-client

Android SDK for Dialogflow
Java
575
star
4

dialogflow-python-client

Python library for Dialogflow
Python
556
star
5

dialogflow-apple-client

iOS SDK for Dialogflow
Objective-C
244
star
6

agent-human-handoff-nodejs

A simple Dialogflow agent, a server, and a web interface that shows an approach for handling text-based conversations between a Dialogflow agent and a human operator
JavaScript
211
star
7

fulfillment-webhook-json

Dialogflow's Fulfillment: Webhook JSON (Requests & Responses)
190
star
8

asr-server

FastCGI support for Kaldi ASR
C++
184
star
9

dialogflow-ruby-client

Ruby SDK for Dialogflow
Ruby
141
star
10

selfservicekiosk-audio-streaming

A best practice for streaming audio from a browser microphone to Dialogflow or Google Cloud STT by using websockets.
JavaScript
140
star
11

dialogflow-java-client

Java client library for Dialogflow
Java
133
star
12

resources

Links to all Dialogflow libraries and samples
119
star
13

fulfillment-weather-nodejs

Integrating an API with Dialogflow's Fulfillment
JavaScript
81
star
14

fulfillment-firestore-nodejs

Integrating Firebase's Firestore database with Dialogflow
JavaScript
81
star
15

fulfillment-bike-shop-nodejs

Integrating Google Calendar API with Dialogflow's Fulfillment & Knowledge Connectors
JavaScript
79
star
16

dialogflow-dotnet-client

.NET framework for Dialogflow
C#
70
star
17

dialogflow-botkit-client

Botkit library for Dialogflow
JavaScript
62
star
18

dialogflow-java-client-v2

Java client for Dialogflow: Design and integrate a conversational user interface into your applications and devices.
59
star
19

dialogflow-unity-client

Unity library for Dialogflow
C#
54
star
20

fulfillment-translate-python

Python
45
star
21

dialogflow-cordova-client

Cordova library for Dialogflow
Objective-C
42
star
22

api-ai-english-asr-model

Api.ai English Speech Recognition (ASR) Model for Kaldi
36
star
23

fulfillment-actions-library-nodejs

Integrating Actions on Google Client Library with Dialogflow's Fulfillment Library
JavaScript
29
star
24

dialogflow-cpp-client

C++ library for Dialogflow
C++
28
star
25

api-ai-cocoa-swift

Cocoa Swift library
Swift
28
star
26

fulfillment-telephony-nodejs

Sample integrating Telephony, Google Sheets, and Slot Filling with Dialogflow
JavaScript
24
star
27

fulfillment-importer-nodejs

Dialogflow's Importer for Alexa Skills to import a Alexa Skill to Dialogflow
JavaScript
22
star
28

fulfillment-slot-filling-nodejs

Slot Filling with Dialogflow Fulfillment
JavaScript
19
star
29

fulfillment-temperature-converter-nodejs

Sample demonstrating how to make a Dialogflow agent compatible with 9 platforms
JavaScript
19
star
30

fulfillment-faq-nodejs

Integrating Dialogflow's Knowledge Connectors, Phone Gateway, and Actions on Google
JavaScript
17
star
31

dialogflow-xamarin-client

Xamarin SDK for Dialogflow
C#
10
star
32

fulfillment-multi-locale-nodejs

Sample showing how to use multiple languages and locales (e.g. English and French)
JavaScript
10
star
33

city-streets-trivia-nodejs

This sample demonstrates how to create and update developer entities using the Dialogflow Node.js Client and the Dialogflow Fulfillment Library. It also demonstrates how to create session entities from your fulfillment code.
JavaScript
10
star
34

fulfillment-regex-nodejs

Validate Entities with Regular Expressions in Dialogflow's Fulfillment
JavaScript
8
star