I want to add a custom casting feature to my Google Home. What I've done so far was the tutorial using Dialogflow from this page: https://developers.google.com/actions/dialogflow/first-app
Then I found a repo about casting videos to Chromecast, only from PC and not from Google Home: https://github.com/googlecast/CastHelloVideo-chrome/blob/master/helloVideos.js
Then I tried combining the two. I've only tried to connect to my Chromecast so far, but I get this error every time:
API Version 2: Failed to parse JSON response string with 'INVALID_ARGUMENT' error: ": Cannot find field.".
I made the tutorial work, so I didn't change anything on Dialogflow, only the index.js file.
This is my file:
'use strict';
process.env.DEBUG = 'actions-on-google:*';
const App = require('actions-on-google').DialogflowApp;
const functions = require('firebase-functions');
// a. the action name from the make_name Dialogflow intent
const NAME_ACTION = 'game_cast';
// b. the parameters that are parsed from the make_name intent
const COLOR_ARGUMENT = 'color';
const NUMBER_ARGUMENT = 'number';
exports.gameCast = functions.https.onRequest((request, response) => {
const app = new App({request, response});
console.log('Request headers: ' + JSON.stringify(request.headers));
console.log('Request body: ' + JSON.stringify(request.body));
// c. The function that generates the silly name
function gameCast (app) {
let number = app.getArgument(NUMBER_ARGUMENT);
let color = app.getArgument(COLOR_ARGUMENT);
// app.tell('Alright, your silly name is ' +
// color + ' ' + number +
// '! I hope you like it. See you next time.');
launchApp();
}
// d. build an action map, which maps intent names to functions
let actionMap = new Map();
actionMap.set(NAME_ACTION, gameCast);
app.handleRequest(actionMap);
});
The launchApp() function call in the gameCast function would connect to my Chromecast. Additionally I added the whole content of helloVideos.js, so there wouldn't be any missing functions that launchApp() may uses. (I didn't include my original file here, as the file helloVideos.js has 617 lines of code.)
Any suggestions would be greatly appreciated! Thanks!