message: pouting_cat: add take_thread_control
diff: @@ -760,7 +760,7 @@ function Facebookbot(configuration) {
  }
  };
  - var handover_protocol = {
  + var handover = {
  get_secondary_receivers_list: function(fields, cb) {
  var uri = 'https://' + api_host + '/v2.6/me/secondary_receivers?' + (fields ? 'fields=' + fields + '&' : '') + 'access_token=' + configuration.access_token;
  request.get(uri,
  @@ -786,6 +786,38 @@ function Facebookbot(configuration) {
  }
  }
  });
  + },
  + take_thread_control: function(recipient, metadata, cb) {
  + var request_body = {
  + recipient: {
  + id: recipient
  + },
  + metadata: metadata
  + };
  + request.post('https://' + api_host + '/v2.6/me/take_thread_control?access_token=' + configuration.access_token,
  + request_body,
  + function(err, res, body) {
  + if (err) {
  + facebook_botkit.log('Could not take thread control');
  + } else {
  +
  + var results = null;
  + try {
  + results = JSON.parse(body);
  + } catch (err) {
  + facebook_botkit.log('ERROR in take thread control API call: Could not parse JSON', err, body);
  + }
  +
  + if (results) {
  + if (results.error) {
  + facebook_botkit.log('ERROR in take thread control API call: ', results.error.message);
  + } else {
  + facebook_botkit.debug('Successfully take thread control', body);
  + cb(result);
  + }
  + }
  + }
  + });
  }
  };
  @@ -795,7 +827,7 @@ function Facebookbot(configuration) {
  'attachment_upload': attachment_upload_api,
  'nlp': nlp,
  'tags': tags,
  - 'handover_protocol': handover_protocol
  + 'handover': handover
  };
  // Verifies the SHA1 signature of the raw request payload before bodyParser parses it
  