message: Add FB handover request thread control
diff: @@ -497,6 +497,9 @@ function Facebookbot(configuration) {
  if (message.take_thread_control) {
  message.type = 'facebook_lose_thread_control';
  }
  + if (message.request_thread_control) {
  + message.type = 'facebook_request_thread_control';
  + }
  next();
  @@ -1134,6 +1137,47 @@ function Facebookbot(configuration) {
  }
  }
  });
  + },
  + request_thread_control: function(recipient, metadata, cb) {
  + var uri = 'https://' + api_host + '/' + api_version + '/me/request_thread_control';
  +
  + if (facebook_botkit.config.require_appsecret_proof) {
  + uri += '&appsecret_proof=' + appsecret_proof;
  + }
  +
  + var request_body = {
  + recipient: {
  + id: recipient
  + },
  + metadata: metadata
  + };
  + request.post({
  + url: uri,
  + qs: {
  + access_token: configuration.access_token
  + },
  + body: request_body,
  + json: true
  + }, function(err, res, body) {
  + if (err) {
  + facebook_botkit.log('Could not request thread control');
  + if (cb) {
  + cb(err);
  + }
  + } else {
  + if (body.error) {
  + facebook_botkit.log('ERROR in request thread control API call: ', body.error.message);
  + if (cb) {
  + cb(body.error);
  + }
  + } else {
  + facebook_botkit.debug('Successfully requested thread control', body);
  + if (cb) {
  + cb(null, body);
  + }
  + }
  + }
  + });
  }
  };
  var broadcast_api = {
  