Carousel buttons

Hi,

2 questions about the carousel template:

  1. Is it possible to show just one button?
  2. How can I navigate to another URL of the site the bot is implemented in when clicking the button?

Hello @philip :smiley:,

Welcome to Kore Community :clap:

Thank you for stopping by!!

If you see the template code when you select carousel,


You will notice that the elements of the carousel are defined in an array. If you use one element it will show only one item. Also, for buttons, if you want to go to a URL, try the below code inside advanced JS section of web/Mobile client override. One button is of type postback - this sends a message to the bot. url can just open a page without asking the bot to do anything.

var elements = [
    {
        "title": "Welcome to Peter's Hats1",
        "image_url": "https://previews.123rf.com/images/rez_art/rez_art1405/rez_art140500072/28632615-three-beef-tacos-with-cheese-lettuce-and-tomatos-Stock-Photo-taco.jpg",
        "subtitle": "carousel subtitle",
        "default_action": {
            "type": "web_url",
            "url": "https://peterssendreceiveapp.ngrok.io/view?item=103"
        },
        "buttons": [{
            "type": "postback",
            "title": "Buy now",
            "payload": "DEVELOPER_DEFINED_PAYLOAD_0"
        }, {
            "type": "web_url",
            "title": "Open Google",
            "url": "https://www.google.com"
        }]
    }];
var message = {
    "type": 'template',
    "payload": {
        "template_type": 'carousel',
        "elements": []
    }
};
message.payload.elements = elements;
print(JSON.stringify(message));

Output.


If you click on Open google, it will open the https://www.google.com