I'm developing a Facebook app that utilizes a messenger bot that posts to my dialogflow agent, which then posts to my backend PHP webhook.
The problem is that I can't find correct documentation to post back a list template.
I have this (working) code to send back a button template:
$array = array(
"source" => $source,
"speech" => 'test string',
"data" => [ "facebook" => [
"attachment" => [
"type" => "template",
"payload" => [
"template_type"=>"button",
"text"=>"Try the URL button!",
"buttons"=>[
[
"type"=>"web_url",
"url"=>"https://www.messenger.com/",
"title"=>"URL Button",
"webview_height_ratio"=>"full"
]
]
]
]
]
],
"displayText" => 'xd',
"contextOut" => array()
);
echo json_encode($array);
To be clear; this code works fine, and I took it from the documentation here: https://developers.facebook.com/docs/messenger-platform/send-messages/template/button
But if I take code from the same source, and adapt it to dialogflow and implement it as show here:
$elementList = array();
foreach ($listings->results as $value) {
array_push($elementList, [
"title" => $value->eventname,
"subtitle"=> $value->description,
"image_url"=> $value->imageurl,
"buttons"=>[
[
"title"=> "View",
"type"=>"web_url",
"url"=>$value->link,
"messenger_extensions"=> true,
"webview_height_ratio"=> "tall",
"fallback_url"=> $value->link
]
]
]);
}
$array = array(
"source" => $source,
"data" => [ "facebook" => [
"attachment" => [
"type" => "template",
"payload" => [
"template_type"=>"list",
"top_element_style"=>"compact",
"elements"=> $elementList,
"buttons"=> [
[
"title"=> "View More",
"type"=> "postback",
"payload"=> "payload"
]
]
]
]
]
],
"contextOut" => array()
);
echo json_encode($array);
The array comes out in the format I want it to, and the same format that is shown in the documentation. But when I post that to dialogflow, and I test it within the messenger client; I get a blank response.
Any guidance is appreciated.