是否可以在前端(Angular)中使用dialogflow-nodejs-client-v2? [英] Is it possible to use dialogflow-nodejs-client-v2 in front-end (Angular)?

查看:58
本文介绍了是否可以在前端(Angular)中使用dialogflow-nodejs-client-v2?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

很久以前,我使用Firebase和dialogflow-javascript-client构建了一个应用程序。



现在,不推荐使用dialogflow-javascript-client。由于dialogflow-nodejs-client-v2是一个node.js客户端,因此不应在Angular上运行。他们放弃了对JavaScript的支持吗?我无法从开发人员那里得到任何答案,他们似乎只是避免使用它。



如果不可能的话,我唯一的解决方案是在我的对话框中放弃对Dialogflow的支持。应用程序。



从Java迁移的用户绝对没有文档或信息,这是他们给您的唯一东西:





当然,我还是尝试运行它,并认为它也可以在javascript上运行。 ..



但这是我得到的:


$ b中的警告$ b ./node_modules/google-gax/node_modules/grpc/node_modules/node-pre-gyp/lib/util/versioning.js
17:20-67关键依赖项:依赖项的请求是
表达式




中的警告。/node_modules/google-gax/node_modules/grpc/node_modules/node-pre-gyp/lib/pre-binding。 js
20:22-48关键依赖性:依赖性请求是
表达式




中的警告。/node_modules/google- gax / node_modules / grpc / src / grpc_extension.js
32:12-33关键依赖项:依赖项的请求是
表达式




中的警告。/node_modules/google-gax/node_modules/grpc/node_modules/minimatch/minimatch.js
找不到模块:错误:无法解析
'D'中的'path': \ngww-app\node_modules\google-gax\node_modules\grpc\node_modules\minimatch'



./ node_modules /中的警告minimatch / minimatch.js找不到模块:
错误:无法解析 D:\ng\ww-app\node_modules\minimatch中的 path


$ ./node_modules/dialogflow/src/v2/agents_client.js中的b $ b

ERROR找不到
的模块:错误:无法解析
中的../agents_client_config'D:\ ng\ww-app\node_modules\dialogflow\src\v2'



....(以下更多内容)



解决方案

dialogflow-nodejs-client-v2 仅支持node.js环境。要将您的代理更新到V2,您应该创建一个 Firebase云功能,将请求发送到 dialogflow-nodejs-client-v2 ,然后从Angular代码中调用该Cloud Function,而不是直接调用API。



此方法的主要优点是:您将不再在客户端公开API凭据,这是安全隐患。


I built an app a long time ago using Firebase and dialogflow-javascript-client.

Now, dialogflow-javascript-client is deprecated. Since dialogflow-nodejs-client-v2 is a node.js client, it is not supposed to run on Angular. Did they drop the javascript support? I can't get any answer from the devs, they just seem to avoid it.

If it is not possible, my only solution is to drop support of Dialogflow in my app.

There is absolutely not documentation or info for users migrating from Javascript, here is the only thing they give you:

Off course I tried to run it anyway, thinking it was also built to run on javascript...

But here is what I get:

WARNING in ./node_modules/google-gax/node_modules/grpc/node_modules/node-pre-gyp/lib/util/versioning.js 17:20-67 Critical dependency: the request of a dependency is an expression

WARNING in ./node_modules/google-gax/node_modules/grpc/node_modules/node-pre-gyp/lib/pre-binding.js 20:22-48 Critical dependency: the request of a dependency is an expression

WARNING in ./node_modules/google-gax/node_modules/grpc/src/grpc_extension.js 32:12-33 Critical dependency: the request of a dependency is an expression

WARNING in ./node_modules/google-gax/node_modules/grpc/node_modules/minimatch/minimatch.js Module not found: Error: Can't resolve 'path' in 'D:\ng\ww-app\node_modules\google-gax\node_modules\grpc\node_modules\minimatch'

WARNING in ./node_modules/minimatch/minimatch.js Module not found: Error: Can't resolve 'path' in 'D:\ng\ww-app\node_modules\minimatch'

ERROR in ./node_modules/dialogflow/src/v2/agents_client.js Module not found: Error: Can't resolve './agents_client_config' in 'D:\ng\ww-app\node_modules\dialogflow\src\v2'

.... (many more following)

解决方案

The dialogflow-nodejs-client-v2 only supports a node.js environment. To update your agent to V2, you should create a Cloud Function for Firebase that sends requests to dialogflow-nodejs-client-v2, then call that Cloud Function from your Angular code rather than calling the API directly.

There is a major benefit of this approach: you will no longer have your API credentials exposed on the client side, which is a security risk.

这篇关于是否可以在前端(Angular)中使用dialogflow-nodejs-client-v2?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆