[英]Can I Implement a Casting Feature for Google Home Customized for My Needs?
I want to add a custom casting feature to my Google Home. 我想向我的Google Home添加自定义投射功能。 What I've done so far was the tutorial using Dialogflow from this page: https://developers.google.com/actions/dialogflow/first-app
到目前为止,我所做的是从以下页面开始的使用Dialogflow的教程: 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 然后,我找到了有关仅将视频从PC而不是从Google Home投射到Chromecast的回购协议: 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:
到目前为止,我只尝试连接到我的Chromecast,但是每次都会出现此错误:
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. 我完成了本教程的工作,因此我没有对Dialogflow进行任何更改,仅更改了index.js文件。
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. gameCast函数中的launchApp()函数调用将连接到我的Chromecast。 Additionally I added the whole content of helloVideos.js, so there wouldn't be any missing functions that launchApp() may uses.
另外,我添加了helloVideos.js的全部内容,因此不会有launchApp()可能使用的任何缺少的函数。 (I didn't include my original file here, as the file helloVideos.js has 617 lines of code.)
(我未在此处包括原始文件,因为文件helloVideos.js具有617行代码。)
Any suggestions would be greatly appreciated! 任何建议将不胜感激! Thanks!
谢谢!
" Cannot find field" comes when your google action intent name is different from gamecast on the api.ai console. 当您的Google动作意图名称与api.ai控制台上的Gamecast不同时,会出现“找不到字段”。
You can goto google cloud back end https://console.cloud.google.com and check the logging error. 您可以转到google cloud后端https://console.cloud.google.com并检查日志记录错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.