简体   繁体   English

谷歌家庭将卡发送到谷歌主页应用程序

[英]Google home to send card to the Google Home app

I made a small Google Home App and my service returns a response with a SimpleMessage + Card. 我制作了一个小型Google Home应用程序,我的服务使用SimpleMessage + Card返回响应。

It works perfectly when running the app in the console.actions.google.com simulator. 在console.actions.google.com模拟器中运行应用程序时,它非常有效。 I get the card all good. 我得到的卡都很好。

But when I test talking to the Google Home, it only sends the text, no trace of the Cards anywhere. 但是当我测试与Google Home的对话时,它只发送文本,没有任何卡片的痕迹。

However If i talk to the Google home app on my phone, it does send the card correctly. 但是,如果我在手机上与谷歌家庭应用程序通话,它会正确发送卡。

Is there something to enable to be able to receive cards sent by Google Home? 是否有能力接收Google Home发送的卡片? Is it possible at all? 有可能吗?

There is no way to make cards that were sent while the user is talking via Google Home visible, but there are several techniques that you, as a developer, can use if cards are necessary. 当用户通过Google Home进行通话时,无法制作发送的卡片,但如果需要卡片,您可以使用多种技术作为开发人员。

First of all - good design suggests that cards should be use to supplement the conversation, not be the focus of the conversation. 首先 - 良好的设计表明,卡片应该用于补充对话,而不是对话的焦点。 Make sure the voice conversation itself is important and use the visual elements only when necessary. 确保语音对话本身很重要,并仅在必要时使用可视元素。 If your action is overly visual - it may be better suited as a mobile or web app, rather than an Action. 如果您的操作过于直观 - 它可能更适合作为移动或网络应用,而不是动作。

If your device requires a screen, then you can set this in the Action Console when you configure your question. 如果您的设备需要屏幕,则可以在配置问题时在操作控制台中进行设置。 This will, however, prevent it from being used on a Google Home device. 但是,这会阻止它在Google Home设备上使用。

在此输入图像描述

If you don't want to go this route, and want to allow it to be used on a smart speaker, but still take advantage of a screen where it is available, you have a few options. 如果你不想走这条路线,并希望允许它在智能扬声器上使用,但仍然利用可用的屏幕,你有几个选择。

First is that you can just send the cards. 首先,你可以发送卡片。 As you've discovered, they won't show up, but they won't cause any problems. 正如您所发现的那样,它们不会出现,但它们不会造成任何问题。

If you want to act slightly differently if a screen is available, you can check for the surface capabilities that the user's Assistant is capable of at that moment. 如果您希望屏幕可用时略有不同,则可以检查用户助手当时的表面功能 If you're using the node.js library, you can have a command such as 如果您正在使用node.js库,则可以使用如下命令

let hasScreen = app.hasSurfaceCapability(app.SurfaceCapabilities.SCREEN_OUTPUT)

to determine if a screen is available and take action based on the variable hasScreen . 确定屏幕是否可用并根据变量hasScreen采取措施。 If you're using JSON, you need to check the array at surface.capabilities or data.google.surface.capabilities to see if "actions.capability.SCREEN_OUTPUT" is one of the available surfaces. 如果您使用JSON,你需要检查在阵列surface.capabilitiesdata.google.surface.capabilities ,看看是否"actions.capability.SCREEN_OUTPUT"是可用的表面之一。

If not, and you get to a point in the conversation where you feel you need to send a visual result, you can also request to continue the conversation on a device that does support screen output. 如果没有,并且您在对话中找到了您认为需要发送可视结果的点,您还可以请求在支持屏幕输出的设备上继续对话。

First, you'll need to make sure that they have a screen available. 首先,您需要确保他们有可用的屏幕。 You'll do this with the node.js library with something like 你可以用node.js库做类似的事情

const screenAvailable = app.hasAvailableSurfaceCapabilities(app.SurfaceCapabilities.SCREEN_OUTPUT);

or by checking the availableSurfaces.capabilities or data.google.availableSurfaces.capabilities parameters in JSON. 或者通过检查JSON中的availableSurfaces.capabilitiesdata.google.availableSurfaces.capabilities参数。

If one is available, you can request to continue the conversation there with something like 如果有一个可用,您可以请求继续与那里的对话

app.askForNewSurface(context, notif, [app.SurfaceCapabilities.SCREEN_OUTPUT]);

where context is the message that will be said on the Google Home, and notif is the notification that will appear on their mobile device (for example) to let them continue the conversation. context是将在Google Home上显示的消息,并且notif将显示在他们的移动设备上(例如)让他们继续对话。 If using JSON, you'll need to use a actions.intent.NEW_SURFACE next intent. 如果使用JSON,则需要使用actions.intent.NEW_SURFACE下一个意图。

Either way, the user will get a notification on their mobile device. 无论哪种方式,用户都将在他们的移动设备上收到通知。 Selecting the notification will start up the Assistant on that device and your Action will be called again with parameters that let you check if they are on the new surface. 选择通知将启动该设备上的助手,并再次使用参数调用您的操作,以便检查它们是否在新表面上。 If so - you can send the card. 如果是这样 - 你可以发送卡。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM