简体   繁体   English

为什么按钮在Google Assistant中不起作用?

[英]Why does the button not work in Google Assistant?

I attempt to add a button onto my action on Google assistant, but the code only works for the first one. 我试图在我的Google助手操作上添加一个按钮,但是该代码仅适用于第一个。 Here is where I add in the button for the ones that don't work: 在这里,我为不起作用的按钮添加按钮:

'Biology': {
title: 'Biology',
text:'Press the button to visit our site for more info. Biology is an important subject for those who are willing to take it, and this website will provide you' +
'with the necessary skill for this subject.',
image: new Image({
  url: 'https://www.edzuki.com/biology/Biology+Edzuki.jpg',
  alt: 'Biology as a subject',
}),
button: new Button({
  title:'Click for the Biology Page',
  url: 'https://www.edzuki.com/biology/',
}),

and, for some reason, this one works 并且由于某种原因,这个作品

'Art': {
title: 'Art',
text:'Press the button to visit our site for more info. Art is an important subject for those who are willing to take it, and this website will provide you' +
'with the necessary skill for this subject.',
image: new Image({
  url: 'https://www.edzuki.com/art/Art.jpg',
  alt: 'Art as a subject',
}),
buttons: new Button({
title: 'Click for Art',
url: `https://www.edzuki.com/art/`,
}),
display: 'WHITE',
},

for const subjectCard (a basic card). 用于const subjectCard(基本卡)。 No errors are thrown by the assistant, just no button is visible. 助手不会抛出任何错误,只是没有可见的按钮。 Why is this? 为什么是这样? Thanks in advance. 提前致谢。

In your first example you use the key button for your button, but in the second example you use buttons with an 's'. 在第一个示例中,您将button用作按钮,而在第二个示例中,您将buttons使用带有“ s”的buttons The docs also suggest you should be using the plural version buttons and your own code should show you this works based on your second working example 文档还建议您使用复数版本buttons并且您自己的代码应根据第二个工作示例向您展示此作品

https://developers.google.com/actions/assistant/responses#basic_card https://developers.google.com/actions/assistant/responses#basic_card

eg 例如

'Biology': {
title: 'Biology',
text:'Press the button to visit our site for more info. Biology is an important subject for those who are willing to take it, and this website will provide you' +
'with the necessary skill for this subject.',
image: new Image({
  url: 'https://www.edzuki.com/biology/Biology+Edzuki.jpg',
  alt: 'Biology as a subject',
}),
buttons: new Button({
  title:'Click for the Biology Page',
  url: 'https://www.edzuki.com/biology/',
}),

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

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