我已经设置了我的第一个Google Action ( basic ),当我测试它(console.actions.google.com)时,基本卡中的图片会以它们的原始比例显示。当我部署在Dialogflow中制作的代理时,图片被扭曲成错误的纵横比。太小了。无论原始图片的比例是什么,它们都被更改为2:3 (w:h)。
发布于 2020-07-15 18:54:58
不幸的是,这个问题不能单独使用dialogflow来解决。要解决此问题,您应该通过实现来构建卡片响应。属性'display' : 'CROPPED'
。负责调整图像的大小。您可以使用内联编辑器来执行此操作。我已经添加了一个可以在内联编辑器中使用的代码示例。
有关更多信息,请查看来自谷歌的文档:https://developers.google.com/assistant/conversational/df-asdk/rich-responses#BasicCardSamples
function cardFunction(agent) {
let conv = agent.conv();
conv.ask(new BasicCard({
text: `This is a basic card. Text in a basic card can include "quotes" and
most other unicode characters including emojis. Basic cards also support
some markdown formatting like *emphasis* or _italics_, **strong** or
__bold__, and ***bold itallic*** or ___strong emphasis___ as well as other
things like line \nbreaks`, // Note the two spaces before '\n' required for
// a line break to be rendered in the card.
subtitle: 'This is a subtitle',
title: 'Title: this is a title',
buttons: new Button({
title: 'This is a button',
url: 'https://assistant.google.com/',
}),
image: new Image({
url: 'https://storage.googleapis.com/actionsresources/logo_assistant_2x_64dp.png',
alt: 'Image alternate text',
}),
display: 'CROPPED',
}));
agent.add(conv)
}
https://stackoverflow.com/questions/62894627
复制相似问题