MessengerExtensions.beginShareFlow()

During F8 2019, we announced our plans to launch a lighter, better and simpler Messenger designed to build closer connections between people and businesses.

Starting August 15, 2019, updated versions of the Messenger app will no longer support Begin share flow on Messenger extension SDK. As a workaround, developers can provide a way, to copy a link within the webview, that people can use to share in Messenger conversations. Refer to June 10, 2019 Announcement

The beginShareFlow() method of the Messenger Extensions SDK allows you to customize the message that is sent when someone shares a page from the webview. For example, you can set the text of the message sent with the shared content, or structure the message using one of the Messenger Platform's templates.

Contents

Method

MessengerExtensions.beginShareFlow(success, error, message, mode)

Example

let message = {
  "attachment":{
    "type":"template",
    "payload":{
      "template_type":"generic",
      "elements": [{
        "title":"I took Peter's 'Which Hat Are You?' Quiz",
        "image_url": "https://bot.peters-hats.com/img/hats/fez.jpg",
        "subtitle": "My result: Fez",
        "default_action":{
          "type":"web_url",
          "url": "https://bot.peters-hats.com/view_quiz_results.php?user=24601"
        },
        "buttons":[{
          "type":"web_url",
          "url":"https://bot.peters-hats.com/hatquiz.php?referer=24601",
          "title":"Take the Quiz"
        }]
      }]
    }
  }
};

MessengerExtensions.beginShareFlow(function(share_response) {
  // User dismissed without error, but did they share the message?
  if(share_response.is_sent){
    // The user actually did share. 
    // Perhaps close the window w/ requestCloseBrowser().
  }
}, 
function(errorCode, errorMessage) {      
// An error occurred in the process

},
message,
"broadcast");

Parameters

Parameter Type Description

success

Function

Success callback function. Receives the share_response object as an argument.

error

Function

Error callback function. Called if Messenger was unable to initiate the share flow.

message

Object

The message to send that links to the shared content. The message must use one of the following:

  • An image
  • Generic template
  • Media template

mode

String

The type of share flow to initiate:

  • broadcast: Prompts the person to share with other people outside the current conversation.
  • current_thread: Prompts the person to share directly to the conversation the webview was opened from.

share_response Object

The share_response object is passed to the success callback.

{
  "is_sent": true  
}

Properties

Property Type Description

is_sent

Boolean

Will be true if the person successfully shared the webview content, and false if they canceled before completing the share.