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

Why does the button not work in Google Assistant?

我尝试在 Google 助手上的操作上添加一个按钮,但该代码仅适用于第一个。这是我为不起作用的按钮添加的地方:

'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/',
}),

而且,出于某种原因,这个有效

'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(基本卡片)。 助手不会抛出任何错误,只是看不到任何按钮。为什么是这样? 提前致谢。

在第一个示例中,您使用键 button 作为按钮,但在第二个示例中,您使用 buttons 和 's'。文档还建议您应该使用复数形式 buttons 并且您自己的代码应该根据您的第二个工作示例

向您展示此作品

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

例如

'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/',
}),