Web/Mobile List template default back postback

Below is my code for the list I want when user clicks on the list element there should be a postback URL by the default action.

I don’t want to use the button for it, ideally, it should because I did the same thing for Widget SDK list and it works fine.

var info = [“Element1”, “Element2”, “Element3”,];
var message = {
“type”: “template”,
“payload”: {
“template_type”: “list”,
“elements”: []

}

};
for (i = 0; i < info.length; i++) {
//if element doesn’t need to have buttons
var element = { //

"default_action": {
        "type": "postback",
        "payload": "payload"
       
    },
    "title": info[i],
    "subtitle": "Description of the element",
    
};

message.payload.elements.push(element);

}
print(JSON.stringify(message));

image

so when click on the element should be postback how do I achieve this.

Hi @rohit.marathe,

We observe that there are missing snippets in the List template code.

var info = [“Element1”, “Element2”, “Element3”];
var message = {
“type”: “template”,
“payload”: {
“template_type”: “list”,
“elements”: [],
“buttons”: [
{
“title”: “View More”,
“type”: “postback”,
“payload”: “payload”
}
]
}
};
for (i = 0; i < info.length; i++) {
//if element doesn’t need to have buttons
var element = {
“title”: info[i],
“image_url”: “image url of the element”,
“subtitle”: “Description of the element”,
“default_action”: {
"type": “web_url”,
"url": “Url to redirect when user clicks on the element”,
“messenger_extensions”: true,
“webview_height_ratio”: “tall”,
“fallback_url”: “fallback url”
}
};

message.payload.elements.push(element);

}
print(JSON.stringify(message));

Kindly check with the above code and let us know if you are observing the issue even after adding the URL attribute.

Regards,
Yoga Ramya