简体   繁体   English

如何使用 dialogflow-nodejs-client-v2 将 Dialogflow API v2 与 MS BotFramework 集成

[英]How to integrate Dialogflow API v2 with MS BotFramework using dialogflow-nodejs-client-v2

I am building a bot using MS BotFramework functions and I am trying to use Dialogflow with MS BotFramework but I am failing with setting up configuration.我正在使用 MS BotFramework 函数构建一个机器人,我正在尝试将 Dialogflow 与 MS BotFramework 一起使用,但我无法设置配置。 dialogflow-nodejs-client-v2 library requires that GOOGLE_APPLICATION_CREDENTIALS environment variable is set. dialogflow-nodejs-client-v2 库要求设置GOOGLE_APPLICATION_CREDENTIALS环境变量。 Which I believe I set :我相信我设置了:

在此处输入图片说明

I've also manually uploaded conf file into the, what I believe is the working directory我还手动将 conf 文件上传到我认为是工作目录

在此处输入图片说明

Yet bot is still failing.然而 bot 仍然失败。 I tried various paths as value of a variable including absolute path : D:\\home\\site\\wwwroot\\messages\\test-0691d01dae88.json我尝试了各种路径作为变量的值,包括绝对路径: D:\\home\\site\\wwwroot\\messages\\test-0691d01dae88.json

still with no luck.仍然没有运气。

Error I am getting is very cryptic :我得到的错误非常神秘:

Exception while executing function: Functions.messages. mscorlib: One or more errors occurred. Error: package.json does not exist at D:\home\site\wwwroot\package.json
at Object.module.exports.exports.find (D:\home\site\wwwroot\.funcpack\index.js:272715:15)
at Object.module.exports.exports.status.OK (D:\home\site\wwwroot\.funcpack\index.js:51739:12)
at __webpack_require__ (D:\home\site\wwwroot\.funcpack\index.js:21:30)
at Object.<anonymous> (D:\home\site\wwwroot\.funcpack\index.js:271412:12)
at __webpack_require__ (D:\home\site\wwwroot\.funcpack\index.js:21:30)
at Object.module.exports.module.exports (D:\home\site\wwwroot\.funcpack\index.js:84837:27)
at __webpack_require__ (D:\home\site\wwwroot\.funcpack\index.js:21:30)
at Object.<anonymous> (D:\home\site\wwwroot\.funcpack\index.js:260961:14)
at __webpack_require__ (D:\home\site\wwwroot\.funcpack\index.js:21:30)
at new GrpcClient (D:\home\site\wwwroot\.funcpack\index.js:132359:25).

It suggest package.json is missing but this error only occurs if I try to use dialog flow to be specific I require recognizer.js file in index.js.它表明缺少 package.json 但只有当我尝试使用特定的对话流时才会发生此错误我需要在 index.js 中使用识别器.js 文件。

var apiairecognizer_v2 = require('./recognizer');

It's content is :它的内容是:

"use strict";
const dialogflow = require('dialogflow').v2beta1;
const uuid = require('uuid');
// next line causes error 
const sessionClient = new dialogflow.SessionsClient();

var ApiAiRecognizer = function(){
};

ApiAiRecognizer.prototype.recognize = function (context, done){
}

module.exports = ApiAiRecognizer;

Commenting out sessionClient line will make bot work.注释掉 sessionClient 行将使机器人工作。

Any idea how to configure Dialogflow v2 with MS BotFramework functions?知道如何使用 MS BotFramework 函数配置 Dialogflow v2 吗?

thanks谢谢

Error seems straight forward for any node.js application.对于任何 node.js 应用程序,错误似乎都很简单。 You are using statement:您正在使用语句:

var apiairecognizer_v2 = require('./recognizer');

So application is expecting package.json file for installing packages like:所以应用程序需要 package.json 文件来安装如下软件包:

{
  "name": "abc",
  "devDependencies": {
     "dialogflow":"^0.6.0",
     "uuid":"^3.3.2",
     "recognizer":"^0.0.2"
  }
}

it is used for installing package by npm.它用于通过 npm 安装包。

Error is that it is expecting package.json with all referenced & dependent packages there in location D:\\home\\site\\wwwroot\\package.json错误在于它期望package.json包含所有引用和依赖的包,位于D:\\home\\site\\wwwroot\\package.json

You can either manually add that or try going to that folder if node is installed & npm is used, try如果安装了节点并使用 npm,您可以手动添加或尝试转到该文件夹​​,请尝试

npm install --save recognizer 

or或者

npm install --save-dev recognizer

it will save latest package in package.json.它将在 package.json 中保存最新的包。

It seems you are already getting two packages dialogflow & uuid resolved using npm without error so issue is missing recognizer entry in package.json.似乎您已经使用 npm 解决了两个包dialogflowuuid没有错误,因此问题是在 package.json 中缺少recognizer条目。 Try adding package in package.json there.尝试在 package.json 中添加包。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM