Search code examples
actions-on-google

It gives error when I put button in Carousel


It gives error and throws me out of app. I want to go youtube link when i push a selected item. When i delete buttons it works but it doesn't go link url. error is MalformedResponse Failed to parse Dialogflow response into AppResponse because of invalid platform response: Could not find a RichResponse or SystemIntent in the platform response

    conv.ask(new Carousel({
        items: {
            'item 1': {
                title: 'item 1',
                buttons: new Button({
                    title: 'This is a button',
                    url: 'https://www.youtube.com/',
                }),
                url: 'https://www.youtube.com/',
                description: 'Description of item 1',
                image: new Image({
                    url: 'https://www.youtube.com/',
                    alt: 'aa',
                })
            },

            'item 2': {
                title: 'item 2',
                buttons: new Button({
                    title: 'This is a button 2',
                    url: 'https://www.youtube.com/',
                }),
                url: 'https://www.youtube.com',
                description: 'Descript',
                image: new Image({
                    url: 'https://www.youtube.com/',
                    alt: 'item 2',
                })
            },
        },
    }));    

Solution

  • If you want a set of items with links, you will want to use a BrowseCarousel instead of a regular carousel. Keep in mind that a BrowseCarousel doesn't have buttons.

    conv.ask(new BrowseCarousel({
        items: [
          new BrowseCarouselItem({
            title: 'Title of item 1',
            url: 'https://example.com',
            description: 'Description of item 1',
            image: new Image({
              url: 'https://storage.googleapis.com/actionsresources/logo_assistant_2x_64dp.png',
              alt: 'Image alternate text',
            }),
            footer: 'Item 1 footer',
          }),
          new BrowseCarouselItem({
            title: 'Title of item 2',
            url: 'https://example.com',
            description: 'Description of item 2',
            image: new Image({
              url: 'https://storage.googleapis.com/actionsresources/logo_assistant_2x_64dp.png',
              alt: 'Image alternate text',
            }),
            footer: 'Item 2 footer',
          }),
        ],
      }));