Search code examples
facebookwebviewfacebook-messengerfacebook-messenger-bot

"image_aspect_ratio" flag not respected while sharing from Messenger BOT webview


I'm trying to make a share from the webview of my bot. Here's my code

var messageToShare = {
            "attachment":{
              "type":"template",
              "payload":{
                "template_type":"generic",
                "image_aspect_ratio":"square",
                "elements":[
                   {
                    "title":"Welcome to Peter\'s Hats",
                    "subtitle":"We\'ve got the right hat for everyone.",
                    "image_url":"https://pbs.twimg.com/profile_images/735453447718338561/9W-MTtOo_400x400.jpg",
                    "buttons":[
                      {
                        "type":"web_url",
                        "url": "my share url",
                        "title":"View Website"
                      }
                    ]
                  }
                ]
              }
            }
        }
MessengerExtensions.beginShareFlow(
  function success() {},
  function error(errorCode, errorMessage) {},
  messageToShare,
  "broadcast"
);

The share is working, but it's not posting the image as expected. The "image_aspect_ratio" flag is not respected and the image is displayed with horizontal layout.

But the same JSON displays the image as a square when the share is done thru CURL. Is there something wrong with my share object ? Please help


Solution

  • It was a bug on Messenger platform. I reported about it to Facebook and now it has beed fixed. https://developers.facebook.com/bugs/391245647960177/