图片未在 Google 上的操作中以丰富的响应显示

Image donot show in rich response in actions on Google

图像不显示在富媒体响应的基本卡片中 我提供了图片 url 但它没有显示图片

@Prisoner 这是我的代码,如果我做错了请告诉我

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

});

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

要获得您需要使用的 URL,您需要 select 该页面顶部的三个点,然后 "Embed item"。您不想使用整个嵌入代码 - 只是 URL.

按照以下步骤寻求解决方案:

  1. 从驱动器中获取可共享的 link URL。
  2. 打开终端(UNIX)并执行此命令。也可以使用基于在线 unix 或本地终端

    https://www.tutorialspoint.com/execute_bash_online.php
    
  3. 执行以下代码

    echo <paste your link> | cut -d '/' -f 6
    
  4. 复制唯一标识的输出。

  5. 粘贴在&id=之后:

    https://drive.google.com/uc?export=view&id=<paste the output unique key>