dialogflow / dialogflow-fulfillment-nodejs

Dialogflow agent fulfillment library supporting v1&v2, 8 platforms, and text, card, image, suggestion, custom responses
Apache License 2.0
597 stars 282 forks source link

Support Node >6 #156

Open kjanoudi opened 5 years ago

kjanoudi commented 5 years ago

This line should be "node": ">=6.0.0", it's causing issues with deploying to engines based on node 8 and up. Not sure why it was changed here: https://github.com/dialogflow/dialogflow-fulfillment-nodejs/commit/b8028247b849d7dea2d2e303a88ef109a0f0aa58#diff-b9cfc7f2cdf78a7f4b91a753d10865a2

https://github.com/dialogflow/dialogflow-fulfillment-nodejs/blob/5994311c2155b2571a6de50250665e18d5d375f8/package.json#L12

mattcarrollcode commented 5 years ago

What kind of issues are you seeing?

kjanoudi commented 5 years ago

When trying to build with yarn on node 8:

@matthewayne error dialogflow-fulfillment@0.6.1: The engine "node" is incompatible with this module. Expected version "6". Got "8.12.0"

mattcarrollcode commented 5 years ago

What is your environment/how are you installing/importing the library?

kjanoudi commented 5 years ago

I have it as a dependency in a GCP hosted cloud function deployed by serverless with webpack. It serves as fulfillment to a dialogflow agent without using actions on Google or the Google assistant.

aradwyr commented 5 years ago

@kjanoudi Cloud Firebase only allows for "node" to either be "6" or "8". Not "8.12.0", I hope that helps

mattcarrollcode commented 5 years ago

@kjanoudi I take it your cloud function is using node 8?

kjanoudi commented 5 years ago

@matthewayne correct. @sarahdwyer it does not work with 8 either.

kjanoudi commented 5 years ago

Is there any particular feature or requirement that is not supported by Node 8 and would expand this change by more than just a package.json modification?

Askir commented 5 years ago

I have basically the same error when trying to add it to a custom node server:

error dialogflow-fulfillment@0.6.1: The engine "node" is incompatible with this module. Expected version "6". Got "10.8.0"
aradwyr commented 5 years ago

@kjanoudi Cloud Firebase works fine for me with Node: "8", can you post all of your dependencies?

kjanoudi commented 5 years ago

@sarahdwyer

    "dialogflow": "^0.7.0",
    "dialogflow-fulfillment": "^0.6.1",
    "firebase-admin": "^6.0.0",
    "humanize-duration": "^3.15.3",
    "uuid": "^3.3.2"

It works fine with this change: https://github.com/dialogflow/dialogflow-fulfillment-nodejs/pull/157/files

However, without it, I get error dialogflow-fulfillment@0.6.1: The engine "node" is incompatible with this module. Expected version "6". Got "8.12.0"

kjanoudi commented 5 years ago

Any progress on this? @sarahdwyer

Vadorequest commented 5 years ago

Same error on my side:

error dialogflow-fulfillment@0.6.1: The engine "node" is incompatible with this module. Expected version "6". Got "8.10.0"

Vadorequest commented 5 years ago

Here is the package.json I downloaded (had to move to node6 to fetch it)

{
  "name": "dialogflow-fulfillment",
  "description": "Dialogflow Fulfillment Library for Node.js",
  "main": "src/dialogflow-fulfillment.js",
  "version": "0.6.1",
  "license": "Apache-2.0",
  "author": "Google Inc.",
  "directories": {
    "test": "test"
  },
  "engines": {
    "node": "6"
  },
  "scripts": {
    "test": "npm run lint && ava",
    "lint": "eslint --fix \"src/**/*.js\" \"test/*.js\" \"script/*.js\"",
    "docs": "node ./generateDocs.js",
    "zip": "npm run zip:actions-on-google && npm run zip:multilocale && npm run zip:temperature-converter && npm run zip:quick-start",
    "zip:actions-on-google": "node ./script/generateZip.js --indexjs ./samples/actions-on-google/functions/index.js --packagejson ./samples/actions-on-google/functions/package.json --agentzip ./samples/actions-on-google/actions-on-google-agent.zip",
    "zip:multilocale": "node ./script/generateZip.js --indexjs ./samples/multi-lang-and-locale/functions/index.js --packagejson ./samples/multi-lang-and-locale/functions/package.json --agentzip ./samples/multi-lang-and-locale/multilocale-agent.zip",
    "zip:temperature-converter": "node ./script/generateZip.js --indexjs ./samples/parameters-contexts-and-rich-responses/functions/index.js --packagejson ./samples/parameters-contexts-and-rich-responses/functions/package.json --agentzip ./samples/parameters-contexts-and-rich-responses/temperature-converter-agent.zip",
    "zip:quick-start": "node ./script/generateZip.js --indexjs ./samples/quick-start/functions/index.js --packagejson ./samples/quick-start/functions/package.json --agentzip ./samples/quick-start/quickstart-agent.zip"
  },
  "repository": {
    "type": "git",
    "url": "git+https://github.com/dialogflow/dialogflow-fulfillment-nodejs.git"
  },
  "bugs": {
    "url": "https://github.com/dialogflow/dialogflow-fulfillment-nodejs/issues"
  },
  "homepage": "https://github.com/dialogflow/dialogflow-fulfillment-nodejs#readme",
  "keywords": [
    "dialogflow",
    "api.ai",
    "client library",
    "webhook",
    "fulfillment"
  ],
  "dependencies": {
    "debug": "^3.1.0",
    "lodash": "^4.17.11"
  },
  "peerDependencies": {
    "actions-on-google": "^2.4.1"
  },
  "devDependencies": {
    "ava": "^0.24.0",
    "eslint": "^4.15.0",
    "eslint-config-google": "^0.9.1",
    "jsdoc-to-markdown": "^4.0.1",
    "jszip": "^3.1.5",
    "commander": "^2.15.1"
  }
}

I believe the change was made (see below), but the npm package wasn't updated, still using hardcoded node 6 version.

https://github.com/dialogflow/dialogflow-fulfillment-nodejs/blob/master/package.json#L12

Vadorequest commented 5 years ago

@matthewayne @kjanoudi I believe releasing a new npm version would just fix this issue :)


Workaround: yarn add dialogflow-fulfillment actions-on-google --ignore-engines

See https://stackoverflow.com/questions/45088031/how-to-ignore-incompatible-engine-node-error-on-installing-npm-dependencies-wi

sarupbanskota commented 5 years ago

Hi @Vadorequest you're running that workaround on a custom server correct? (i.e not Cloud Functions?)

Vadorequest commented 5 years ago

@sarupbanskota Yes, I'm running my function on AWS Lambda

The workaround is executed on my personal computer, I use the Serverless Framework to deploy the stack. (if you're not familiar with SLS framework, just consider that I do the build on my computer, then deploy that build on AWS, which is similar with having a custom server)

The workaround can be used both on personal computers (localhost, development env) and on a server (production env)

I do not know how to skip "engines" check on Firebase, but if you deploy on AWS/GCP/Azure, the workaround should be the same.

sarupbanskota commented 5 years ago

The workaround can be used both on personal computers (localhost, development env) and on a server (production env)

Indeed; I was looking for a way to use the yarn flag on a Firebase deployment.

Haven't used it yet, but I like the idea of deploying a local build via SLS Framework - more predictable. Will give it a try - thanks!

kjanoudi commented 5 years ago

Can we get a new npm release for this? I see it's fixed in master

Vadorequest commented 5 years ago

The best workaround I've found isn't the --ignore-engines but simply changing the path for the package in package.json

"dialogflow-fulfillment": "dialogflow/dialogflow-fulfillment-nodejs",

Avoids additional issues.

sariroti commented 5 years ago

Thanks for the solution, yet this is causing error in my google cloud build.

Can the package.json modified so we don't need to use --ignore-engines ?

ivan-kaminskyi commented 5 years ago

I suffer from this problem too. Can`t deploy to firebase functions using firebase-cli. Only installing it from master branch directly from repository helps.

ajays97 commented 5 years ago

Solved it by installing packages

Just do yarn add or npm install and any of the above packages.

syntholly commented 5 years ago

How is this still a problem, @matthewayne, with 118cfa083c38fdb938c8d0d4452eca6d4df69b35 now in master? Is the npm module being neglected?

I imagine my use-case is similar to others: I develop on a 10.x or 12.x Node.js locally, and copy those versions to my production server.

@ajays97, your fix is almost perfect - at least from a yarn perspective:

I couldn't do an yarn add dialogflow-fulfillment/dialogflow-fulfillment-nodejs, instead I just dropped that link in my package.json and did a yarn install.

myhendry commented 5 years ago

i managed to install the 2 packages (dialogflow-fulfillment and actions-on-google) successfully using the following yarn command in terminal...

yarn add https://github.com/dialogflow/dialogflow-fulfillment-nodejs
yarn add actions-on-google
Vadorequest commented 5 years ago

@myhendry This should have worked too. https://github.com/dialogflow/dialogflow-fulfillment-nodejs/issues/156#issuecomment-442795321

myhendry commented 5 years ago

Thanks Vadorequest. However will inserting the flag --ignore-engines cause problems when deploying to heroku or aws?

Vadorequest commented 5 years ago

No, it won't. That flag basically means you're ignoring the engine check, nothing more. So, even if it's specified in the package that it's not compatible with node 6, then it will passe the engine check even if installing using node !6. It doesn't change the behaviour of node whatsoever, it's only related to the package installation sanity checks. :)

myhendry commented 5 years ago

Thanks @Vadorequest for the clarification

alankleindev commented 3 years ago

Is there a replacement for the associated NPM Module? It is 2020 and I getting the same error. This repo hasn't been touched in 2+ years.

Some dependencies could not be validated. The node version for dialogflow-fulfillment package is incompatible.

Is there a replacement we should be using from Google or is this just not being maintained anymore and their is no replacement? The Google documentation leads you here, which makes it quite confusing.

syntholly commented 3 years ago

@alankleindev, does this serve your purposes better?

I've not made a voice agent in a while, I was just dipping in to see what's changed - turns out nothing (sadly). I did find that package though and it's updated information.

alankleindev commented 3 years ago

Thanks @vSanjo. I was looking for a library so I didn't have to manually construct the JSON response, as detailed here.

Text Response

{
  "fulfillmentMessages": [
    {
      "text": {
        "text": [
          "Text response from webhook"
        ]
      }
    }
  ]
}

I looked at Dialogflow API: Node.js Client, but it seems to not have the methods to do so, compared to dialogflow-fulfillment-nodejs, but i could be overseeing it. Basically, was looking for a more steamlined way to create the Webhook fulfullment responses instead of manually constructing JSON.

Thanks for pointing out this repo though.

It seems like about 2 years ago, most of the effort into creating content for Dialogflow dropped off, based on what I see published.

syntholly commented 3 years ago

I can only agree with you, @alankleindev. I've had similar experiences and thankfully not needed to put much energy into exploring it just yet - but I will soon, I imagine.

On the one hand, creating them ourselves seems to be the 'expected' way moving forwards. It's almost purer, precise and extendable without opinion from other modules. On the other hand, it's so much more extra work facilitating that change, especially if you're doing it from scratch.

Your point about the effort for creating new things for DialogFlow dropping off is accurate and saddening. I'd love to explore why that's happening and where that effort has shifted to.

Good luck moving over!