简体   繁体   English

如何在 Google Dialogflow Fullfilment Inline Editor 中安装 npm 包

[英]How to install npm packages within Google Dialogflow Fullfilment Inline Editor

I would like to install some npm packages into my chatbot but I cant make this working.我想在我的聊天机器人中安装一些 npm 包,但我无法使其正常工作。

package.json file looks as below: package.json 文件如下所示:

{
  "name": "dialogflowFirebaseFulfillment",
  "description": "This is the default fulfillment for a Dialogflow agents using Cloud Functions for Firebase",
  "version": "0.0.1",
  "private": true,
  "license": "Apache Version 2.0",
  "author": "Google Inc.",
  "engines": {
    "node": "~6.0"
  },
  "scripts": {
    "start": "firebase serve --only functions:dialogflowFirebaseFulfillment",
    "deploy": "firebase deploy --only functions:dialogflowFirebaseFulfillment"
  },
  "dependencies": {
    "actions-on-google": "^1.5.x",
    "firebase-admin": "^4.2.1",
    "firebase-functions": "^0.5.7",
    "apiai": "^4.0.3"
  }
}

In index.js I have:在 index.js 我有:

var jsonQuery = require('json-query');

The logs says: dialogflowFirebaseFulfillment Function load error: Code in file index.js can't be loaded.日志显示:dialogflowFirebaseFulfillment 函数加载错误:无法加载文件 index.js 中的代码。 Did you list all required modules in the package.json您是否在 package.json 中列出了所有必需的模块

Any idea?有什么想法吗?

The error arrived because you didn't include package 'json-query'出现错误是因为您没有包含包“json-query”

run below command after all working fine.在所有工作正常后运行以下命令。

npm install json-query

Answer is simpler than you would think (and @Dhaval mentioned it).答案比您想象的要简单(@Dhaval 也提到了)。 You only have to include the name of the npm package in package.json :你只需要在package.json包含 npm 包的名称:

{
"some": "crazyPropsFoo",
"engines": {},
"scripts": {},
"dependencies": {
  "actions-on-google": "^1.5.x",
  "firebase-admin": "~4.1.2",
  "firebase-functions": "~0.5",
  "npmpackage": "1.8.0",        //Here it is
  "apiai": "^4.0.3"
  }
}

Then require that package in your index.js file:然后require该包在你的index.js文件:

var PackageObj = require("npmpackage").PackageObject;
var yourVar = new PackageObj();

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

相关问题 如何在嵌入式编辑器dialogflow中发出发布请求? - how to make post request in inline editor dialogflow? 在Dialogflow的内联编辑器中基于当前日期计算将来的日期 - Calculating future dates based on curent date within inline editor for Dialogflow 无法在Dialogflow内联编辑器中发出HTTP请求 - Unable to make http request from within Dialogflow inline editor 在Dialogflow内联编辑器上在Google Webhook示例上部署事务 - Deploying the transactions on google webhook sample on dialogflow inline editor 如何使用Firestore在DialogFlow完整文件上显示快照中的值 - How to display a value from snap on DialogFlow fullfilment using Firestore 内联编辑器中的对话流捕获实体 - dialogflow capturing entity in inline editor 如何使用DialogFlow在线编辑器从Firebase检索数据 - How to retrieve data from Firebase using DialogFlow Inline Editor 将丰富的消息集成到 Dialogflow fullfilment - Integrate rich message into Dialogflow fullfilment 如何安装全局安装的 npm 包 - How to install globally installed npm packages NPM v7+ - 如何使用“lockfileVersion”安装软件包:1 - NPM v7+ - How to install packages with "lockfileVersion": 1
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM