Reputation: 2479
I'm creating a chatbot app with angular 6 and I want to use the dialogflow sdk. Because the sdk is just for javascript, I also added the typings for dialogflow.
package.json:
dependencies: {
[...]
"@types/dialogflow": "0.6.3",
"dialogflow": "0.6.0
}
I tried many different imports:
import { SessionsClient } from 'dialogflow';
import { SessionsClient, v2 } from 'dialogflow';
import * as dialogflow from 'dialogflow';
import 'dialogflow'
But I'm always getting the error
MODULE_NOT_FOUND
When I try to use it
this.dialogflowSessionsClient = new SessionsClient();
this.dialogflowSessionsClient = new v2.SessionsClient();
this.dialogflowSessionsClient = new dialogflow.SessionsClient();
The IDE can resolve the reference. So, what am I doing wrong?
UPDATE
I tried it also in a new angular project and now I have a better error message. Unfortunately, it doesn't help me either.
./node_modules/dialogflow/src/v2/agents_client.js
Module not found: Error: Can't resolve './agents_client_config' in '/Users/[my-project-path]/node_modules/dialogflow/src/v2'
Upvotes: 1
Views: 1267
Reputation: 507
I am doing the same thing, there is a front-end JS client library available in this link. All I had to do was use npm to install it and then import it into my Ionic project, but there is very little maintenance so honestly I would suggest using the newer HttpClient library or some other good REST library and make the REST calls using the v2 reference docs.
Google describes how they map REST calls to their gRPC protocol in their http protobuf, they call it "transcoding".
I know this is a more difficult way than using a client library, but honestly it will be much more worth it than using a library with minimal support (at least until there is a better maintained client library.)
Upvotes: 1