Carousel question


#1

Hello i have a question about the carousel functionality can we put the text from a renderer on a card

can i set the text propertie with a text renderer from render.js file so
i have a carousel card with a text property

“text”:

can i set this with
await event.reply(’#summary’, state);


#2

To explain it better i have used the built in carousel:
“formData”: [
{
“title”: “Card1”,
“typing”: true,
“text”: “”
},
{
“title”: “Card2”,
“typing”: true,
“text”: “”
}
]

Can i use a render method i have in mij render.js for the text property on my card?


#3

Sorry, I don’t think this is possible. You could define your own renderer reneding carousel with some text in it like this:

  '#documents': data => {
    return {
        on: 'webchat',
        type: 'carousel',
        typing: '1s',
        text: 'Documents',
        settings: {
          responsive: [
            // ...
            { breakpoint: 1000, settings: { slidesToShow: 4 } },
            { breakpoint: 10000, settings: { slidesToShow: 5 } }
          ]
        },
        elements: (data.documents || []).map(doc => ({
          title: doc.name,
          subtitle: doc.preview,
          buttons: [{ url: doc.url, title: 'View document' }]
        }))
      }
  }

#4

i have not been able to render a carousel i just get a empty message i have used your code :

 '#documents': data => {
    return {
        on: 'webchat',
        type: 'carousel',
        typing: '1s',
        text: 'Documents',
        settings: {
          responsive: [
            // ...
            { breakpoint: 1000, settings: { slidesToShow: 4 } },
            { breakpoint: 10000, settings: { slidesToShow: 5 } }
          ]
        },
        elements: (data.documents || []).map(doc => ({
          title: doc.name,
          subtitle: doc.preview,
          buttons: [{ url: doc.url, title: 'View document' }]
        }))
      }
  }

in my renderer.js and in action js i have

  renderCarousel: async (state, event) => {
        await event.reply('#documents', state);
    },

am i missing something as of now i just get an empty message?


#5

Did you try to debug your code? Is action called? Is renderer called?


#6

Hi alex thanks for your reply the action is getting called the renderer is getting called but i get a empty message the output is :
Capture


#7

I think an issue is in renderer: make sure it receives correct data and renders what it should. )