首页 > 解决方案 > Image donot show in rich response in actions on Google

问题描述

Images donot show in basic card in rich response I have provided the url of image but it didn't show an image

@Prisoner here is my code, please let me know if i am doing any mistake

app.intent('totalResponses', (conv, { Location }) => {
  // extract the num parameter as a local string variable

  if (!conv.surface.capabilities.has('actions.capability.SCREEN_OUTPUT')) {
    conv.ask('Sorry, try this on a screen device or select the ' +
      'phone surface in the simulator.');
    return;
  }

  conv.ask('Hello World');

  conv.ask(new BasicCard({
    text: `Hello`, // Note the two spaces before '\n' required for
                                 // a line break to be rendered in the card.
    title: 'Title: this is a title',
    image: new Image({
      url: 'https://drive.google.com/file/d/13eEr2rYhSCEDKDwCLab29AqFMsKuOi4P/view',
      alt: 'Image alternate text',
    }),
  }));

});

标签: actions-on-googledialogflow-es

解决方案


问题在于您用于图像的驱动器 URL。当您直接从 Google Drive 加载图像时,此 URL 用于预览图像。它是一个 HTML 页面,而不是图像,因此如果您在网页或助手卡片中使用它,它不会显示。

要获取您需要使用的 URL,您需要选择该页面顶部的三个点,然后选择“嵌入项目”。您不想使用整个嵌入代码 - 只是 URL。

在此处输入图像描述


推荐阅读