I want to integrate my Dialogflow chatbot with my existing ionic4 App using Angular Typescript but I'm having problems importing it for use within my project. How best can I import the dialogflow NodeJS client for use in my Ionic or Angular App ??
I started a blank Ionic4 Angular project and installed the dialogflow client library:
npm install dialogflow
and I have also installed the dialogflow typescript using:
npm install --save @types/dialogflow
I have also updated my tsconfig.app.json to be;
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "./out-tsc/app",
"types": ["node","dialogflow"]
},
Method 1 : the initialisation in dialogflow docs
dialogflow = require('dialogflow');
Method 2: Alternate initialisation
import { SessionsClient } from 'dialogflow';
constructor(public platform: Platform) {
const sessionClient = new SessionsClient();
const sessionPath = sessionClient.sessionPath('project-ID', 'session-ID');
}
In Both cases when I try to use the library, this error is coming up
On the web App it's showing this error:
Failed to compile.
./node_modules/google-gax/build/src/operationsClient.js
Module not found: Error: Can't resolve './operations_client_config' in '/home/dev/MobileApps/goatChat/node_modules/google-gax/build/src'
On the console its showing this error:
ERROR in ./node_modules/google-gax/build/src/operationsClient.js
Module not found: Error: Can't resolve './operations_client_config' in '/home/dev/MobileApps/goatChat/node_modules/google-gax/build/src'
ERROR in ./node_modules/google-auth-library/build/src/auth/googleauth.js
Module not found: Error: Can't resolve 'child_process' in '/home/dev/MobileApps/goatChat/node_modules/google-auth-library/build/src/auth'
ERROR in ./node_modules/google-auth-library/build/src/auth/googleauth.js
Module not found: Error: Can't resolve 'fs' in '/home/dev/MobileApps/goatChat/node_modules/google-auth-library/build/src/auth'
ERROR in ./node_modules/google-p12-pem/build/src/index.js
Module not found: Error: Can't resolve 'fs' in '/home/dev/MobileApps/goatChat/node_modules/google-p12-pem/build/src'
ERROR in ./node_modules/gtoken/build/src/index.js
Module not found: Error: Can't resolve 'fs' in '/home/dev/MobileApps/goatChat/node_modules/gtoken/build/src'
ERROR in ./node_modules/request/lib/har.js
Module not found: Error: Can't resolve 'fs' in '/home/dev/MobileApps/goatChat/node_modules/request/lib'
ERROR in ./node_modules/forever-agent/index.js
Module not found: Error: Can't resolve 'net' in '/home/dev/MobileApps/goatChat/node_modules/forever-agent'
ERROR in ./node_modules/gaxios/node_modules/https-proxy-agent/index.js
Module not found: Error: Can't resolve 'net' in '/home/dev/MobileApps/goatChat/node_modules/gaxios/node_modules/https-proxy-agent'
ERROR in ./node_modules/tough-cookie/lib/cookie.js
Module not found: Error: Can't resolve 'net' in '/home/dev/MobileApps/goatChat/node_modules/tough-cookie/lib'
ERROR in ./node_modules/tunnel-agent/index.js
Module not found: Error: Can't resolve 'net' in '/home/dev/MobileApps/goatChat/node_modules/tunnel-agent'
ERROR in ./node_modules/forever-agent/index.js
Module not found: Error: Can't resolve 'tls' in '/home/dev/MobileApps/goatChat/node_modules/forever-agent'
ERROR in ./node_modules/gaxios/node_modules/https-proxy-agent/index.js
Module not found: Error: Can't resolve 'tls' in '/home/dev/MobileApps/goatChat/node_modules/gaxios/node_modules/https-proxy-agent'
ERROR in ./node_modules/tunnel-agent/index.js
Module not found: Error: Can't resolve 'tls' in '/home/dev/MobileApps/goatChat/node_modules/tunnel-agent'
ℹ 「wdm」: Failed to compile.
What am I doing wrong or how can I correct it ?