app.intent('Input_Welcome', (conv) => {
conv.ask(Welcome, How can I help?);
conv.ask(new Suggestions(intentSuggestions));
});
app.intent('Control_Devices',(conv, { devices, status }) => {
return admin.database().ref(/ESP8266/${devices}/value).set(status)
.then(snapshot => {
conv.ask(OK, switching ${devices} ${status}. Do you want more?);
conv.ask(new Suggestions(intentSuggestions));
});
});
app.intent('Get_Status_Devices',(conv, { devices }) => {
return admin.database().ref(/ESP8266/${devices}).once("value")
.then(snapshot => {
var sta = snapshot.child("value").val();
conv.ask(${devices} status is + sta + . Do you want more?);
conv.ask(new Suggestions(intentSuggestions));
});
});
exports.dialogflowFirebaseFulfillment = functions.https.onRequest(app);
//----------------------------------------------------------------------------------//
**And code in 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": "8"
},
"scripts": {
"start": "firebase serve --only functions:dialogflowFirebaseFulfillment",
"deploy": "firebase deploy --only functions:dialogflowFirebaseFulfillment"
},
"dependencies": {
"actions-on-google": "^2.2.0",
"firebase-admin": "^5.13.1",
"firebase-functions": "^2.0.2",
"dialogflow": "^0.6.0",
"dialogflow-fulfillment": "^0.5.0"
}
}
//--------------------------------------------------------------------------//
When I test on Actions-on-Google:
The database in Firebase is changed, buts have no response of Google. Only error:
MalformedResponse
Failed to parse Dialogflow response into AppResponse because of invalid platform response: Could not find a RichResponse or SystemIntent in the platform response for agentId: 4cbca294-9872-4dbc-86ee-daf947e3962e and intentId: 1001f2c2-3ea9-43a6-bcf4-0b796e943616. WebhookStatus: code: 4 message: "Webhook call failed. Error: DEADLINE_EXCEEDED." ..
I have inline code in index.js: //-----------------------------------------------------------------------------// 'use strict'; const functions = require('firebase-functions'); const admin = require('firebase-admin'); admin.initializeApp({ credential: admin.credential.applicationDefault(), databaseURL: 'https://nodemculed-d7408.firebaseio.com' }); const { dialogflow, BasicCard, BrowseCarousel, BrowseCarouselItem, Button, Carousel, Image, LinkOutSuggestion, List, MediaObject, Suggestions, SimpleResponse, Table } = require('actions-on-google');
const intentSuggestions = [ 'Control', 'Get Status', 'light on', 'light off', 'light status', 'fan on', 'fan off', 'fan status', ]; const app = dialogflow();
app.intent('Input_Welcome', (conv) => { conv.ask(
Welcome, How can I help?
); conv.ask(new Suggestions(intentSuggestions)); });app.intent('Control_Devices',(conv, { devices, status }) => { return admin.database().ref(
/ESP8266/${devices}/value
).set(status) .then(snapshot => { conv.ask(OK, switching ${devices} ${status}. Do you want more?
); conv.ask(new Suggestions(intentSuggestions)); }); });app.intent('Get_Status_Devices',(conv, { devices }) => { return admin.database().ref(
/ESP8266/${devices}
).once("value") .then(snapshot => { var sta = snapshot.child("value").val(); conv.ask(${devices} status is
+ sta +. Do you want more?
); conv.ask(new Suggestions(intentSuggestions)); });}); exports.dialogflowFirebaseFulfillment = functions.https.onRequest(app); //----------------------------------------------------------------------------------//
**And code in 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": "8" }, "scripts": { "start": "firebase serve --only functions:dialogflowFirebaseFulfillment", "deploy": "firebase deploy --only functions:dialogflowFirebaseFulfillment" }, "dependencies": { "actions-on-google": "^2.2.0", "firebase-admin": "^5.13.1", "firebase-functions": "^2.0.2", "dialogflow": "^0.6.0", "dialogflow-fulfillment": "^0.5.0" } } //--------------------------------------------------------------------------// When I test on Actions-on-Google: The database in Firebase is changed, buts have no response of Google. Only error: MalformedResponse Failed to parse Dialogflow response into AppResponse because of invalid platform response: Could not find a RichResponse or SystemIntent in the platform response for agentId: 4cbca294-9872-4dbc-86ee-daf947e3962e and intentId: 1001f2c2-3ea9-43a6-bcf4-0b796e943616. WebhookStatus: code: 4 message: "Webhook call failed. Error: DEADLINE_EXCEEDED." ..
How can i fix this problem ? Pls help me!