我想在Google Home中添加自定义投射功能。到目前为止我所做的是使用此页面中的Dialogflow的教程:https://developers.google.com/actions/dialogflow/first-app
然后我找到了一个关于将视频投射到Chromecast的回购,仅限于PC,而不是来自Google Home:https://github.com/googlecast/CastHelloVideo-chrome/blob/master/helloVideos.js
然后我尝试将两者结合起来。到目前为止,我只尝试连接到我的Chromecast,但每次都会出现此错误:
API Version 2: Failed to parse JSON response string with 'INVALID_ARGUMENT' error: ": Cannot find field.".
我使教程工作,所以我没有改变Dialogflow上的任何内容,只改变了index.js文件。
这是我的档案:
'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);
});
gameCast函数中的launchApp()函数调用将连接到我的Chromecast。另外我添加了helloVideos.js的全部内容,因此不会有任何缺少launchApp()可能使用的函数。 (我在这里没有包含我的原始文件,因为文件helloVideos.js有617行代码。)
任何建议都将不胜感激!谢谢!
答案 0 :(得分:0)
您可以转到google cloud back end https://console.cloud.google.com并检查日志记录错误。