Reputation: 159
I was testing the new code according to v2. Link: Build Your First App with Dialogflow code:
'use strict';
const {dialogflow} = require('actions-on-google');
const functions = require('firebase-functions');
const app = dialogflow({debug: true});
app.intent('Default Welcome Intent', conv => {
console.log("-----welcome intent-----");
conv.ask('Welcome');
});
exports.testMain = functions.https.onRequest(app);
But when I simulate it, it shows :
MalformedResponse
'final_response' must be set.
What can I do? The request is not reaching the function though Fulfillment is enabled.
---------UPDATED------------
now I am getting this error when I try to deploy the function to firebase:
Function load error: Code in file index.js can't be loaded
Is there a syntax error in your code?
Detailed stack trace: TypeError: dialogflow is not a funct
at Object.<anonymous> (/user_code/index.js:6:13)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at getUserFunction (/var/tmp/worker/worker.js:388:24)
at loadUserCode (/var/tmp/worker/worker.js:444:18)
I am unable to understand???
Here is my package.json:
{
"name": "some name",
"description": "some desc",
"version": "0.0.1",
"author": "Google Inc.",
"engines": {
"node": "~4.2"
},
"dependencies": {
"actions-on-google": "^1.0.0",
"firebase-admin": "^5.11.0",
"firebase-functions": "^1.0.0",
"dialogflow": "^0.3.0",
"request": "^2.85.0",
"uuid": "^3.0.1"
}
}
------update 2------ I have changed node to :
"engines": {
"node": "~6.0"
still same problem
-----Update 3--------
Deployment complete, but when the request goes to it, it shows:
Upvotes: 1
Views: 824
Reputation: 159
changed the package.json:
"engines": {
"node": "~6.11.1"
},
"dependencies": {
"actions-on-google": "^2.0.0",
"firebase-admin": "^5.11.0",
"firebase-functions": "^1.0.0",
"dialogflow": "^0.3.0",
"request": "^2.85.0",
"uuid": "^3.0.1"
}
And this works
Upvotes: 0
Reputation: 349
Trying changing conv.ask('Welcome')
to conv.close('Welcome');
also remove console.log("-----welcome intent-----");
line just for testing
Upvotes: 0
Reputation: 50701
Confirm which version of the actions-on-google library you're using. Your dependencies of "actions-on-google": "^1.0.0"
specifies version 1.x of the library, but the rest of your usage is via the 2.0.0 syntax. The error suggests that there is no dialogflow
object, which is also provided in version 2 of the library, but not version 1.
To use version 2.0.0 and up, you need to change the line in your package.json to
"actions-on-google": "^2.0.0"
and then run
npm update
Upvotes: 1
Reputation: 50701
Check what version of node you're using. The package.json suggests that you're using node 4, when you need to be using at least node 6 if you're using =>
.
Since Firebase Cloud Functions is node 6 as well, you should likely switch to it for your local development as well. (Node itself is at version 8 for LTS, and working on version 9, so you should certainly consider updating.)
Upvotes: 0
Reputation: 1810
Make sure that fulfillment
is enable in the Dialogflow dashboard and that v2
of the API is turned on? Also check that the intent name you are using in your fulfillment matches the one in Dialogflow.
Your code looks good to me. Its probably a configuration issue.
Upvotes: 0