dialogflow / dialogflow-javascript-client Goto Github PK
View Code? Open in Web Editor NEWJavaScript Web SDK for Dialogflow
License: Apache License 2.0
JavaScript Web SDK for Dialogflow
License: Apache License 2.0
Apparently you cannot access microphone via getUserMedia
in Safari on OSX and Safari/Chrome on iOS due to OS limitation, so the recorder is not working.
I think a reference to which browsers are currently supported would be helpful.
I'm guessing this library isn't meant to be run server side, but I was having problems with the API.ai official libs and tried it to get the issue below
removing your package the problem went away.
../node_modules/@types/webrtc/RTCPeerConnection.d.ts(35,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'type' must be of type 'string', but here has type 'RTCSdpType'.
../node_modules/@types/webrtc/RTCPeerConnection.d.ts(35,5): error TS2687: All declarations of 'type' must have identical modifiers.
../node_modules/@types/webrtc/RTCPeerConnection.d.ts(41,14): error TS2403: Subsequent variable declarations must have the same type. Variable 'type' must be of type 'string', but here has type 'RTCSdpType'.
../node_modules/@types/webrtc/RTCPeerConnection.d.ts(41,14): error TS2687: All declarations of 'type' must have identical modifiers.
../node_modules/@types/webrtc/RTCPeerConnection.d.ts(42,14): error TS2687: All declarations of 'sdp' must have identical modifiers.
../node_modules/@types/webrtc/RTCPeerConnection.d.ts(59,5): error TS2687: All declarations of 'candidate' must have identical modifiers.
../node_modules/@types/webrtc/RTCPeerConnection.d.ts(66,14): error TS2687: All declarations of 'candidate' must have identical modifiers.
../node_modules/@types/webrtc/RTCPeerConnection.d.ts(67,14): error TS2687: All declarations of 'sdpMid' must have identical modifiers.
../node_modules/@types/webrtc/RTCPeerConnection.d.ts(68,14): error TS2687: All declarations of 'sdpMLineIndex' must have identical modifiers.
../node_modules/@types/webrtc/RTCPeerConnection.d.ts(204,5): error TS2687: All declarations of 'maxFramerate' must have identical modifiers.
../node_modules/@types/webrtc/RTCPeerConnection.d.ts(240,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'degradationPreference' must be of type 'string', but here has type 'RTCDegradationPreference'.
../node_modules/@types/webrtc/RTCPeerConnection.d.ts(315,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'iceTransportPolicy' must be of type 'string', but here has type 'RTCIceTransportPolicy'.
../node_modules/@types/webrtc/RTCPeerConnection.d.ts(316,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'bundlePolicy' must be of type 'string', but here has type 'RTCBundlePolicy'.
../node_modules/@types/webrtc/RTCPeerConnection.d.ts(401,6): error TS2300: Duplicate identifier 'RTCSessionDescriptionCallback'.
../node_modules/@types/webrtc/RTCPeerConnection.d.ts(405,6): error TS2300: Duplicate identifier 'RTCPeerConnectionErrorCallback'.
../node_modules/@types/webrtc/RTCPeerConnection.d.ts(409,6): error TS2300: Duplicate identifier 'RTCStatsCallback'.
../node_modules/@types/webrtc/RTCPeerConnection.d.ts(428,14): error TS2403: Subsequent variable declarations must have the same type. Variable 'signalingState' must be of type 'string', but here has type 'RTCSignalingState'.
../node_modules/@types/webrtc/RTCPeerConnection.d.ts(429,14): error TS2403: Subsequent variable declarations must have the same type. Variable 'iceGatheringState' must be of type 'string', but here has type 'RTCIceGatheringState'.
../node_modules/@types/webrtc/RTCPeerConnection.d.ts(430,14): error TS2403: Subsequent variable declarations must have the same type. Variable 'iceConnectionState' must be of type 'string', but here has type 'RTCIceConnectionState'.
../node_modules/@types/webrtc/RTCPeerConnection.d.ts(432,14): error TS2687: All declarations of 'canTrickleIceCandidates' must have identical modifiers.
../node_modules/@types/webrtc/RTCPeerConnection.d.ts(438,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'onnegotiationneeded' must be of type '(this: RTCPeerConnection, ev: Event) => any', but here has type 'EventHandler'.
../node_modules/@types/webrtc/RTCPeerConnection.d.ts(439,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'onicecandidate' must be of type '(this: RTCPeerConnection, ev: RTCPeerConnectionIceEvent) => any', but here has type '(event: RTCPeerConnectionIceEvent) => void'.
../node_modules/@types/webrtc/RTCPeerConnection.d.ts(441,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'onsignalingstatechange' must be of type '(this: RTCPeerConnection, ev: Event) => any', but here has type 'EventHandler'.
../node_modules/@types/webrtc/RTCPeerConnection.d.ts(442,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'oniceconnectionstatechange' must be of type '(this: RTCPeerConnection, ev: Event) => any', but here has type 'EventHandler'.
../node_modules/@types/webrtc/RTCPeerConnection.d.ts(443,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'onicegatheringstatechange' must be of type '(this: RTCPeerConnection, ev: Event) => any', but here has type 'EventHandler'.
../node_modules/@types/webrtc/RTCPeerConnection.d.ts(491,13): error TS2403: Subsequent variable declarations must have the same type. Variable 'RTCPeerConnection' must be of type '{ new (configuration: RTCConfiguration): RTCPeerConnection; prototype: RTCPeerConnection; }', but here has type 'RTCPeerConnectionStatic'.
../node_modules/@types/webrtc/RTCPeerConnection.d.ts(492,13): error TS2403: Subsequent variable declarations must have the same type. Variable 'RTCSessionDescription' must be of type '{ new (descriptionInitDict?: RTCSessionDescriptionInit): RTCSessionDescription; prototype: RTCSes...', but here has type 'RTCSessionDescriptionStatic'.
../node_modules/@types/webrtc/RTCPeerConnection.d.ts(493,13): error TS2403: Subsequent variable declarations must have the same type. Variable 'RTCIceCandidate' must be of type '{ new (candidateInitDict?: RTCIceCandidateInit): RTCIceCandidate; prototype: RTCIceCandidate; }', but here has type 'RTCIceCandidateStatic'.
../node_modules/typescript/lib/lib.es6.d.ts(20104,11): error TS2300: Duplicate identifier 'RTCSessionDescriptionCallback'.
../node_modules/typescript/lib/lib.es6.d.ts(20107,11): error TS2300: Duplicate identifier 'RTCPeerConnectionErrorCallback'.
../node_modules/typescript/lib/lib.es6.d.ts(20110,11): error TS2300: Duplicate identifier 'RTCStatsCallback'.
lib/nlp/ApiAiBot.ts(20,11): error TS6133: 'event' is declared but never used.
tests/ApiAiBot.test.ts(1,7): error TS6133: 'test' is declared but never used.
tests/ApiAiBot.test.ts(5,9): error TS6133: 'AppConfig' is declared but never used.
tests/ApiAiBot.test.ts(8,5): error TS6133: 'testmsg' is declared but never used.
Hi,
The typescript variant of IStreamClient
only exposes startListening
, which makes this example uncompilable:
const client = new ApiAi.Client({accessToken: "ACCESS_TOKEN", streamClientClass: ApiAi.ApiAiStreamClient});
const streamClient = client.createStreamClient(); // in that case some default settings will be applied
streamClient.onInit = function () {
console.log("> ON INIT use direct assignment property");
streamClient.open();
};
streamClient.init();
streamClient.startListening();
streamClient.stopListening();
Hi,
In the startUserMedia
method in the StreamClient a GainNode could be added as well to configure the microphone gain.
When I call client.eventRequest('event_name')
as described in the readme, it's treated as a textRequest()
and it doesn't trigger the event passed.
I saw that both EventRequest and TextRequest extend Request without adding any changes.
Hi,
I'm trying to integrate api.ai with my angular 2 (4 beta 8 actually) application but I get these errors:
ERROR in [at-loader] node_modules\api-ai-javascript\ts\Request\Request.ts:25:16
TS2322: Type 'Promise<void>' is not assignable to type 'Promise<IServerResponse>'.
Type 'void' is not assignable to type 'IServerResponse'.
ERROR in [at-loader] node_modules\api-ai-javascript\ts\Request\TTSRequest.ts:63:20
TS2322: Type 'Promise<void>' is not assignable to type 'Promise<{}>'.
Type 'void' is not assignable to type '{}'.
Here the extract of packages.json:
"dependencies": {
"@angular/common": "~4.0.0-beta.8",
"@angular/compiler": "~4.0.0-beta.8",
"@angular/core": "~4.0.0-beta.8",
"@angular/forms": "~4.0.0-beta.8",
"@angular/http": "~4.0.0-beta.8",
"@angular/platform-browser": "~4.0.0-beta.8",
"@angular/platform-browser-dynamic": "~4.0.0-beta.8",
"@angular/router": "~4.0.0-beta.8",
"@angular/compiler-cli": "~4.0.0-beta.8",
"@angular/platform-server": "~4.0.0-beta.8",
"core-js": "^2.4.1",
"reflect-metadata": "^0.1.10",
"rxjs": "5.2.0",
"zone.js": "^0.7.7",
"font-awesome": "4.7.0"
},
"devDependencies": {
"@types/core-js": "^0.9.35",
"@types/jasmine": "^2.5.43",
"@types/node": "^7.0.5",
"@types/selenium-webdriver": "^2.53.39",
"angular2-template-loader": "^0.6.2",
"awesome-typescript-loader": "3.0.7",
"enhanced-resolve": "3.1.0",
"gulp": "3.9.1",
"gulp-clean": "0.3.2",
"gulp-concat": "2.6.1",
"gulp-sass": "3.1.0",
"html-loader": "0.4.4",
"html-minify-loader": "^1.1.0",
"html-webpack-plugin": "2.28.0",
"imports-loader": "0.7.0",
"json-loader": "0.5.4",
"raw-loader": "^0.5.1",
"rimraf": "2.6.0",
"ts-loader": "2.0.1",
"typescript": "2.1.6",
"webpack":"2.2.1",
"webpack-dev-server": "2.4.1",
"webpack-visualizer-plugin": "^0.1.10",
"magic-string":"0.19.0",
"@ngtools/webpack":"^1.2.10",
"api-ai-javascript": "^2.0.0-beta.16"
}
Can you help me?
Thanks,
Alberto
Hey,
I'm using the Typescript version of the apiai-javascript-client in my angular-cli project. When I try to run ng build --prod
I get this error:
ERROR in Error encountered resolving symbol values statically. Reference to a non-exported class ApiAiBaseError. Consider exporting the class, resolving symbol ApiAiClientConfigurationError in /.../node_modules/api-ai-javascript/ts/Errors.ts
It seems like adding an export
in front of abstract class ApiAiBaseError extends Error
fixes the issue, for me at least.
[15:21:42] Starting 'minify-js'...
events.js:160
throw er; // Unhandled 'error' event
^
GulpUglifyError: unable to minify JavaScript
at createError (/home/circleci/tucana/node_modules/gulp-uglify/lib/create-error.js:6:14)
at apply (/home/circleci/tucana/node_modules/gulp-uglify/node_modules/lodash/_apply.js:16:25)
at wrapper (/home/circleci/tucana/node_modules/gulp-uglify/node_modules/lodash/_createCurry.js:41:12)
at /home/circleci/tucana/node_modules/gulp-uglify/lib/minify.js:54:15
at DestroyableTransform._transform (/home/circleci/tucana/node_modules/gulp-uglify/composer.js:10:23)
at DestroyableTransform.Transform._read (/home/circleci/tucana/node_modules/gulp-uglify/node_modules/readable-stream/lib/_stream_transform.js:182:10)
at DestroyableTransform.Transform._write (/home/circleci/tucana/node_modules/gulp-uglify/node_modules/readable-stream/lib/_stream_transform.js:170:83)
at doWrite (/home/circleci/tucana/node_modules/gulp-uglify/node_modules/readable-stream/lib/_stream_writable.js:406:64)
at writeOrBuffer (/home/circleci/tucana/node_modules/gulp-uglify/node_modules/readable-stream/lib/_stream_writable.js:395:5)
at DestroyableTransform.Writable.write (/home/circleci/tucana/node_modules/gulp-uglify/node_modules/readable-stream/lib/_stream_writable.js:322:11)
at write (/home/circleci/tucana/node_modules/readable-stream/lib/_stream_readable.js:623:24)
at flow (/home/circleci/tucana/node_modules/readable-stream/lib/_stream_readable.js:632:7)
at Transform.pipeOnReadable (/home/circleci/tucana/node_modules/readable-stream/lib/_stream_readable.js:664:5)
at emitNone (events.js:86:13)
at Transform.emit (events.js:185:7)
at emitReadable_ (/home/circleci/tucana/node_modules/readable-stream/lib/_stream_readable.js:448:10)
at emitReadable (/home/circleci/tucana/node_modules/readable-stream/lib/_stream_readable.js:444:5)
at readableAddChunk (/home/circleci/tucana/node_modules/readable-stream/lib/_stream_readable.js:187:9)
at Transform.Readable.push (/home/circleci/tucana/node_modules/readable-stream/lib/_stream_readable.js:149:10)
at Transform.push (/home/circleci/tucana/node_modules/readable-stream/lib/_stream_transform.js:145:32)
at Transform._transform (/home/circleci/tucana/node_modules/gulp-ng-annotate/index.js:84:10)
at Transform._read (/home/circleci/tucana/node_modules/readable-stream/lib/_stream_transform.js:184:10)
at Transform._write (/home/circleci/tucana/node_modules/readable-stream/lib/_stream_transform.js:172:12)
at doWrite (/home/circleci/tucana/node_modules/readable-stream/lib/_stream_writable.js:237:10)
at writeOrBuffer (/home/circleci/tucana/node_modules/readable-stream/lib/_stream_writable.js:227:5)
at Transform.Writable.write (/home/circleci/tucana/node_modules/readable-stream/lib/_stream_writable.js:194:11)
at DestroyableTransform.ondata (/home/circleci/tucana/node_modules/gulp-ignore/node_modules/readable-stream/lib/_stream_readable.js:612:20)
at emitOne (events.js:96:13)
at DestroyableTransform.emit (events.js:188:7)
at addChunk (/home/circleci/tucana/node_modules/gulp-ignore/node_modules/readable-stream/lib/_stream_readable.js:284:12)
at readableAddChunk (/home/circleci/tucana/node_modules/gulp-ignore/node_modules/readable-stream/lib/_stream_readable.js:271:11)
at DestroyableTransform.Readable.push (/home/circleci/tucana/node_modules/gulp-ignore/node_modules/readable-stream/lib/_stream_readable.js:238:10)
at DestroyableTransform.Transform.push (/home/circleci/tucana/node_modules/gulp-ignore/node_modules/readable-stream/lib/_stream_transform.js:146:32)
at DestroyableTransform._transform (/home/circleci/tucana/node_modules/gulp-ignore/index.js:18:9)
at DestroyableTransform.Transform._read (/home/circleci/tucana/node_modules/gulp-ignore/node_modules/readable-stream/lib/_stream_transform.js:182:10)
at DestroyableTransform.Transform._write (/home/circleci/tucana/node_modules/gulp-ignore/node_modules/readable-stream/lib/_stream_transform.js:170:83)
at doWrite (/home/circleci/tucana/node_modules/gulp-ignore/node_modules/readable-stream/lib/_stream_writable.js:406:64)
at writeOrBuffer (/home/circleci/tucana/node_modules/gulp-ignore/node_modules/readable-stream/lib/_stream_writable.js:395:5)
at DestroyableTransform.Writable.write (/home/circleci/tucana/node_modules/gulp-ignore/node_modules/readable-stream/lib/_stream_writable.js:322:11)
at write (/home/circleci/tucana/node_modules/readable-stream/lib/_stream_readable.js:623:24)
at flow (/home/circleci/tucana/node_modules/readable-stream/lib/_stream_readable.js:632:7)
at DestroyableTransform.pipeOnReadable (/home/circleci/tucana/node_modules/readable-stream/lib/_stream_readable.js:664:5)
at emitNone (events.js:86:13)
at DestroyableTransform.emit (events.js:185:7)
at emitReadable_ (/home/circleci/tucana/node_modules/readable-stream/lib/_stream_readable.js:448:10)
at emitReadable (/home/circleci/tucana/node_modules/readable-stream/lib/_stream_readable.js:444:5)
at readableAddChunk (/home/circleci/tucana/node_modules/readable-stream/lib/_stream_readable.js:187:9)
at DestroyableTransform.Readable.push (/home/circleci/tucana/node_modules/readable-stream/lib/_stream_readable.js:149:10)
at DestroyableTransform.Transform.push (/home/circleci/tucana/node_modules/readable-stream/lib/_stream_transform.js:145:32)
at afterTransform (/home/circleci/tucana/node_modules/readable-stream/lib/_stream_transform.js:101:12)
at TransformState.afterTransform (/home/circleci/tucana/node_modules/readable-stream/lib/_stream_transform.js:79:12)
at DestroyableTransform.noop [as _transform] (/home/circleci/tucana/node_modules/through2/through2.js:26:3)
at DestroyableTransform.Transform._read (/home/circleci/tucana/node_modules/readable-stream/lib/_stream_transform.js:184:10)
at DestroyableTransform.Transform._write (/home/circleci/tucana/node_modules/readable-stream/lib/_stream_transform.js:172:12)
at doWrite (/home/circleci/tucana/node_modules/readable-stream/lib/_stream_writable.js:237:10)
at writeOrBuffer (/home/circleci/tucana/node_modules/readable-stream/lib/_stream_writable.js:227:5)
at DestroyableTransform.Writable.write (/home/circleci/tucana/node_modules/readable-stream/lib/_stream_writable.js:194:11)
at write (/home/circleci/tucana/node_modules/readable-stream/lib/_stream_readable.js:623:24)
at flow (/home/circleci/tucana/node_modules/readable-stream/lib/_stream_readable.js:632:7)
at DestroyableTransform.pipeOnReadable (/home/circleci/tucana/node_modules/readable-stream/lib/_stream_readable.js:664:5)
at emitNone (events.js:86:13)
at DestroyableTransform.emit (events.js:185:7)
at emitReadable_ (/home/circleci/tucana/node_modules/readable-stream/lib/_stream_readable.js:448:10)
at emitReadable (/home/circleci/tucana/node_modules/readable-stream/lib/_stream_readable.js:444:5)
at readableAddChunk (/home/circleci/tucana/node_modules/readable-stream/lib/_stream_readable.js:187:9)
at DestroyableTransform.Readable.push (/home/circleci/tucana/node_modules/readable-stream/lib/_stream_readable.js:149:10)
at DestroyableTransform.Transform.push (/home/circleci/tucana/node_modules/readable-stream/lib/_stream_transform.js:145:32)
at afterTransform (/home/circleci/tucana/node_modules/readable-stream/lib/_stream_transform.js:101:12)
at TransformState.afterTransform (/home/circleci/tucana/node_modules/readable-stream/lib/_stream_transform.js:79:12)
at /home/circleci/tucana/node_modules/gulp/node_modules/vinyl-fs/lib/src/getContents/bufferFile.js:12:5
at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:446:3)
error Command failed with exit code 1.
Our full minification work and if i do
ApiAi = require 'api-ai-javascript'
that break straight our build
also same problem with import {ApiAiClient} from "api-ai-javascript"
as you can see we use gulp minify and gulp uglify to do that.
We have many differents libs include in our project i don't get why your's break everything 😟
Is this official javascript package available in npm?
I would love to use this on an existing webpack build, but I can't find a maintanable way of doing it since I have to download the package again everytime I want to update.
The node js SDK is already available on npm, so why not this one too? This is the one I need since I'm only making a frontend app.
Hi,
I've been playing for a while with your js SDK and i'm missing a way to get a text string as user is speaking. Using webkitSpeechRecognition you can get instant transcription of the text as user speaks, in real time, while with your SDK you have to wait until a result event is triggered. Is it possible asking for?
Thank you!
Please add License info for the repo
Hi,
I'm using api.ai in an electron app however I am unable to get any results back.
My code looks like this:
var config = {
server: 'wss://api.api.ai:4435/api/ws/query',
token: 'my_access_token',// Use Client access token there (see agent keys).
sessionId: '1234'
};
var apiAi = new ApiAi(config);
apiAi.onInit = function(){
console.log("INITED");
apiAi.open();
}
apiAi.init();
$("link").on('click', function(){
apiAi.startListening();
})
apiAi.onStartListening = function(){
console.log("started listening")
}
apiAi.onResults = function(data){
console.log(data.result);
}
I am able to receive the debug message 'started listening' but I am not receiving any results back after that. However if I do apiAi.sendJson('data to send'), then I receive the results back which means I'm connecting to my agent correctly.
Hi! I have been trying this API (in typescript) and it works very well in English. But I am having some issues with international characters.
For example if I send the request:
"¿Cuál es la población de España?" (which is spanish for "What is the population in Spain?")
It gets resolved (result.resolvedQuery) to:
"¿Cuál es la población de España?"
I noticed that the problem is solved if the HTTPRequest was sent specifying the charset (utf-8) in the Content Type headers.
This could be achieved if line 43 in ts/XhrRequest.ts:
headers["Content-Type"] = "application/json";
Is changed to:
headers["Content-Type"] = "application/json; charset=utf-8";
It works OK and I get the right result.resolvedQuery:
"¿Cuál es la población de España?"
Sample code to reproduce the issue:
this.aiClient = new Client({accessToken: this.token});
this.aiClient.textRequest("¿Cuál es la población de España?")
.then((response:any) => console.log(response.result.resolvedQuery));
For an English speaker using a demo written in English, having the TTS use Russian is kind of confusing. I narrowed it down to a previous issue [#1] and this line:
https://github.com/api-ai/api-ai-javascript/blob/master/demo/js/app.js#L151
Is having the demo speak Russian something that was done on purpose or an oversight? I'm happy to issue a PR to change it to English.
Hi Guys , I am trying the js demo on google chrome and getting this error
ON ERROR 5 No live audio input in this browser
The current version doesn't seem to work with Google Chrome on Android. The reason seems to be navigator.getUserMedia
, which is going to be deprecated. I tried using the navigator.mediaDevices.getUserMedia
promise, but it doesn't work either.
I am trying to build test bot following the way like demo file. But which is not working on IE11.
how to fix ?
In the sauce entity: "no sause" and "without sause"
Hi,
In order to write properly type classes it should be easy to access the relevant types.
At the moment I need to import IServerResponse
like this
import {IServerResponse} from '../../node_modules/api-ai-javascript/ts/Interfaces';
const response: IServerResponse = ...
It would be nice to import it like
import {IServerResponse} from 'api-ai-javascript';
Hi,
I use the streamClient but the websocket-connection closing connection automatically.
I removed lang from client instantiation (so lang is default / en) and now it's working:
const client = new ApiAi.ApiAiClient({
accessToken: '###',
streamClientClass: ApiAi.ApiAiStreamClient,
// lang: 'de'
});
I tested it also with the simple-demo - same results.
Stefan
I'm trying to let users ask questions through their microphones, convert that to text and send it to api.ai. I've implemented the StreamClient example code from the README content and it seems to at least init the stream client since my browser asks me whether I want to allow access to the mic for that web portal. I can also see that the "onInit" function is being triggered.
My initial design is simple: user hits a button on the portal and starts asking the question - once he/she stops talking (1-2 seconds of silence) I'd assume that the speech recorder stops recording and either provides the result in text form (a string that I can use to call the api.ai /query method) or automatically pushes the recoreded audio to api.ai and provides the results from the server as JSON.
How would I achieve that?
Thanks
Kurt
Hi,
I use api.ai with angular 2 and i wanted to access to Parameters object in the response,
but sadly typescript say that it doesn't exist on IServerResponse
By now i have modified IServerResponse to include parameters as "any" type but i wanted to kow if its a "bug" or if you havn't include it consciously ?
By the way, the way thanks for your great job,
Api.Ai is awesome !
See microsoft/TypeScript#15363.
Currently this package publishes .ts files in the package on npmjs, so that rules like noImplicitAny
get picked up when you import { ... } from "api-ai-javascript"
.
The recommendation is to instead publish .js files with the corresponding .d.ts files. See the link at the top of this comment for the issue thread on the TypeScript repo about this.
An example of another repo that has made this change to their TS project publishing: Goyoo/node-k8s-client#37.
Hi,
I need help. I installed api-ai with "npm install api-ai-javascript --save-dev", and put code 'import {ApiAiClient, ApiAiStreamClient} from "api-ai-javascript";' in my code file. It shows lots of errors.
Typescript Error
Property 'AudioContext' does not exist on type 'Window'.
...opbox/Websites/Cueat/App/node_modules/api-ai-javascript/ts/Request/TTSRequest.ts
this.uri = Constants.DEFAULT_TTS_HOST;
const AudioContext = window.AudioContext || webkitAudioContext;
Typescript Error
Cannot find name 'webkitAudioContext'.
...opbox/Websites/Cueat/App/node_modules/api-ai-javascript/ts/Request/TTSRequest.ts
this.uri = Constants.DEFAULT_TTS_HOST;
const AudioContext = window.AudioContext || webkitAudioContext;
Typescript Error
Property 'AudioContext' does not exist on type 'Window'.
...ropbox/Websites/Cueat/App/node_modules/api-ai-javascript/ts/Stream/Processors.ts
_resamplerJSRegisterer();
window.AudioContext = window.AudioContext || webkitAudioContext;
Typescript Error
Property 'AudioContext' does not exist on type 'Window'.
...ropbox/Websites/Cueat/App/node_modules/api-ai-javascript/ts/Stream/Processors.ts
_resamplerJSRegisterer();
window.AudioContext = window.AudioContext || webkitAudioContext;
Typescript Error
Cannot find name 'webkitAudioContext'.
...ropbox/Websites/Cueat/App/node_modules/api-ai-javascript/ts/Stream/Processors.ts
_resamplerJSRegisterer();
window.AudioContext = window.AudioContext || webkitAudioContext;
Typescript Error
Property 'AudioContext' does not exist on type 'Window'.
...pbox/Websites/Cueat/App/node_modules/api-ai-javascript/ts/Stream/StreamClient.ts
try {
window.AudioContext = window.AudioContext || webkitAudioContext;
navigator.getUserMedia =
Typescript Error
Property 'AudioContext' does not exist on type 'Window'.
...pbox/Websites/Cueat/App/node_modules/api-ai-javascript/ts/Stream/StreamClient.ts
try {
window.AudioContext = window.AudioContext || webkitAudioContext;
navigator.getUserMedia =
Typescript Error
Cannot find name 'webkitAudioContext'.
...pbox/Websites/Cueat/App/node_modules/api-ai-javascript/ts/Stream/StreamClient.ts
try {
window.AudioContext = window.AudioContext || webkitAudioContext;
navigator.getUserMedia =
Typescript Error
Property 'webkitGetUserMedia' does not exist on type 'Navigator'.
...pbox/Websites/Cueat/App/node_modules/api-ai-javascript/ts/Stream/StreamClient.ts
navigator.getUserMedia =
navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia;
window.URL = window.URL || window.webkitURL;
Typescript Error
Property 'mozGetUserMedia' does not exist on type 'Navigator'.
...pbox/Websites/Cueat/App/node_modules/api-ai-javascript/ts/Stream/StreamClient.ts
navigator.getUserMedia =
navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia;
window.URL = window.URL || window.webkitURL;
Typescript Error
Cannot find name 'ActiveXObject'.
.../Sync/Dropbox/Websites/Cueat/App/node_modules/api-ai-javascript/ts/XhrRequest.ts
() => new XMLHttpRequest(),
() => new ActiveXObject("Msxml2.XMLHTTP"),
() => new ActiveXObject("Msxml3.XMLHTTP"),
Typescript Error
Cannot find name 'ActiveXObject'.
.../Sync/Dropbox/Websites/Cueat/App/node_modules/api-ai-javascript/ts/XhrRequest.ts
() => new ActiveXObject("Msxml2.XMLHTTP"),
() => new ActiveXObject("Msxml3.XMLHTTP"),
() => new ActiveXObject("Microsoft.XMLHTTP")
Typescript Error
Cannot find name 'ActiveXObject'.
.../Sync/Dropbox/Websites/Cueat/App/node_modules/api-ai-javascript/ts/XhrRequest.ts
() => new ActiveXObject("Msxml3.XMLHTTP"),
() => new ActiveXObject("Microsoft.XMLHTTP")
];
Typescript Error
Supplied parameters do not match any signature of call target.
D:/Documents/Sync/Dropbox/Websites/Cueat/App/src/pages/home/home.ts
M_RequestMenuByText(Text){
const client = new ApiAiClient('YOUR_ACCESS_TOKEN', {streamClientClass: ApiAiStreamClient});
client
Hi,
The startListening and the stopListening
method both have the default scope, which is window
.
Can be fixed with
public startListening = () => {
// ...
}
Typescript treats scopes exactly like javascript: https://github.com/Microsoft/TypeScript/wiki/'this'-in-TypeScript
In API.AI, there are some API like /intents
/contexts
.
But It doesn't seem to be support them in this library, why?
I'll send pull request if reason is just lack of contributor.
Is it possible to use the speech recognition api endpoint through the javascript sdk?
If so, how do I make sure the access_token I use remains secure?
My code was working fine, then uploaded to your new version and got this problem when using the TTS service:
Uncaught (in promise) DOMException: Unable to decode audio data
Adding to bower would make project integration easier. Just a recommendation.
Hi guys,
Can you add an example how I can change recognition language? I'm trying to make Russian eWallet assistant.
What I've tried: change "lang": "RU",
to RU and to create Russian agent on your site.
P.S.: I know some of you are Russian :).
Hello, trying to connect to the websocket but I keep getting the message in the js console "use direct assignment property" and the connection just hangs... without opening nor closing. Thought was a firewall issue but I'm getting that from every device.
When trying to send a json message or record voice, I'm getting the following error from the console:
api.ai.min.js:16 Uncaught InvalidStateError: Failed to execute 'send' on 'WebSocket': Still in CONNECTING state.e.startListening @ api.ai.min.js:16_start @ app.js:188App.start @ app.js:37onclick @ index.html:47
I've used the demo provided here in the past to build a proof-of-concept. Until last Friday (April 16th 2016) both my POC and the provided demo worked fine. Now they don't; I simply never get a call to onResults() and the submitted queries don't show up in the logs in the api.ai console. Neither the demo code nor my POC have been touched and they run on different systems.
What I notice has changed is that now when I call stopListening() the api object is immediately closed (possibly preventing the transmission of the results) where before it stayed open.
Hi!
I'm using the "demo/simple", but I have problems with the long Text because the voice response is breaking after 190 characters.
Could you please help me @Gugic?
The readme's hyperlink under "How to use the agent" is forwarding to an incorrect url.
I installled this package through npm install api-ai-javascript
for my node app, using ecs6.
I require it using var ApiAi = require('api-ai-javascript');
And I have this error :
apppath\node_modules\api-ai-javascript\index.js:1
(function (exports, require, module, __filename, __dirname) { export * from "./srces6/_build";
^^^^^^
SyntaxError: Unexpected reserved word
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:373:25)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (appFileWhereRequireIsDone:1:77)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
I can't understand why there is export
in a js
file, is that not only for ts
?
I also try using this package with files under target path, but I had another error while running an example.
I prefer npm package.
How should I import and use your module?
I'm using Ionic2 with Typescript. Unfortunately I couldn't use the cordova plugin version as type definitions are not available yet.
Running the JS version into my Ionic2 project. After following though the installation steps, I see following error.
Property 'AudioContext' does not exist on type 'Window'.
Cannot find name 'webkitAudioContext'.
How do we fix this?
Hi,
I was wondering if there was a way to disable the microphone request. I'm using the client for text and don't want to have users confirm mic access every time they load the page.
Thanks,
Steve
We have been working on creating of a Prove of Concept integration for Voice support for our application last week and got the base working using the javascript API.
Since last weekend however the integration stopped working. The websocket connection is opened and closed without any feedback data send. Also it looks like the server does not receive any client data either.
Anyone an idea if anything has changed server side that cause the javascript api to stop working?
My project needs to access the device's microphone, and I am trying to achieve it using the Javascript SDK.
Here is the code as follows,
const streamClient = client.createStreamClient();
streamClient.onInit = function () {
console.log("Entered streamClient function");
streamClient.open();
};
The issue is that the streamClient
is not created because webkitAudioContext
is not defined. Why is this issue occuring? Is there a work around for this?
PS: I am able to send and receive text responses using the same SDK. So I guess it is only the microphone part of the SDK that has bugs.
Got a "No live audio input in this browser" on Chrome for Androïd.
Didn't see any prompt.
Let's say I am not bothered with the user typing the text instead of using the mic, how should I switch off the use of microphone?
Thanks.
I'm building my personal website, no audio inputs, just general information about my resume.. And people block their microphones when the browser asks for it.
Hi,
It would be awesome to see the releases along with the changelog in the github release section :)
thanks a lot and for all the work,
Muki
Hi,
When I try to compile the current v2
branch I get
ERROR in [at-loader] node_modules/api-ai-javascript/src/XhrRequest.ts:69:26
Property 'status' does not exist on type 'XMLHttpRequestEventTarget'.
ERROR in [at-loader] node_modules/api-ai-javascript/src/XhrRequest.ts:69:48
Property 'status' does not exist on type 'XMLHttpRequestEventTarget'.
I guess this can be fixed by replacing
if (this.status >= 200 && this.status < 300)
with
if (client.status >= 200 && client.status < 300)
Hi there,
Great potential in this lib, thanks.
Copy pasting the code results in
WebSocket is already in CLOSING or CLOSED state.
which seems to break up the state?
(function() {
'use strict';
angular
.module('findr')
.controller('MainController', MainController);
/** @ngInject */
function MainController($rootScope, $timeout, webDevTec, toastr) {
var vm = this;
var apiAi = new ApiAi($rootScope.apiAiConfig);
vm.classAnimation = '';
vm.Listening = false;
activate();
//
// Private methods
//
function activate() {
$timeout(function() {
vm.classAnimation = 'rubberBand';
}, 4000);
}
function processResult(data) {
console.log('Processing api.ai data')
}
//
// Scope methods
//
vm.startListening = function () {
apiAi.init();
vm.Listening = true;
}
vm.stopListening = function () {
apiAi.stopListening();
apiAi.close();
vm.Listening = false;
}
//
// Api ai events
//
apiAi.onInit = function () {
console.log('onInit');
apiAi.open();
};
apiAi.onOpen = function () {
console.log('onOpen');
console.log(apiAi.isOpen())
apiAi.startListening();
};
apiAi.onClose = function () {
console.log('onClose');
vm.Listening = false;
console.log(apiAi.isOpen())
};
apiAi.onStartListening = function () {
console.log('onStartListening');
vm.Listening = true;
};
/**
* It's triggered when listening is stopped.
*/
apiAi.onStopListening = function () {
console.log('onStopListening');
vm.Listening = false;
console.log(apiAi.isOpen())
};
// apiAi.onEvent = function (code, data) {
apiAi.onError = function (code, data) {
console.log('onError')
console.log(code)
console.log(data)
};
apiAi.onResults = function (data) {
console.log('onResults');
console.log(data)
var status = data.status;
var code;
if (!(status && (code = status.code) && isFinite(parseFloat(code)) && code < 300 && code > 199)) {
text.innerHTML = JSON.stringify(status);
return;
}
processResult(data.result);
};
}
})();
Similar to this perhaps? faye/faye#371
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.