Search code examples
actions-on-googledialogflow-es

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

});

Solution

  • The problem is with the drive URL that you're using for the image. This URL is the one that is used to preview the image when you load it from Google Drive directly. It is an HTML page, rather than an image, so it won't display if you use it in a web page or in a card for the assistant.

    To get the URL you need to use, you want to select the three dots at the top of that page and then "Embed item". You don't want to use the entire embed code - just the URL.

    enter image description here