我正在开发一个Facebook应用程序,它利用一个发布到我的dialogflow代理的messenger机器人,然后发布到我的后端PHP webhook .

问题是我找不到正确的文档来回发列表模板 .

我有这个(工作)代码发回一个按钮模板:

$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);

要清楚;这段代码工作正常,我从这里的文档中获取它:https://developers.facebook.com/docs/messenger-platform/send-messages/template/button

但是,如果我从相同的源代码中获取代码,并将其调整为对话框流并按如下所示实现:

$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);

该阵列以我想要的格式出现,并且与文档中显示的格式相同 . 但是当我将它发布到dialogflow时,我在messenger客户端中测试它;我得到一个空白的答复 .

任何指导表示赞赏 .