diff --git a/lib/CoreBot.js b/lib/CoreBot.js index fe61062ba..842692917 100755 --- a/lib/CoreBot.js +++ b/lib/CoreBot.js @@ -823,7 +823,7 @@ function Botkit(configuration) { // set up a once a second tick to process messages botkit.tickInterval = setInterval(function() { botkit.tick(); - }, 1000); + }, 1500); } }; diff --git a/lib/Facebook.js b/lib/Facebook.js index feabbf7ee..1d4ecdac6 100644 --- a/lib/Facebook.js +++ b/lib/Facebook.js @@ -47,32 +47,35 @@ function Facebookbot(configuration) { facebook_message.message.quick_replies = message.quick_replies; } - request.post('https://graph.facebook.com/me/messages?access_token=' + configuration.access_token, + //Add Access Token to outgoing request + + facebook_message.access_token = configuration.access_token; + + request({ + method: "POST", + json: true, + headers: { + "content-type": "application/json", + }, + body: facebook_message, + uri: 'https://graph.facebook.com/v2.6/me/messages' + }, function(err, res, body) { - if (err) { - botkit.debug('WEBHOOK ERROR', err); - return cb && cb(err); - } - - try { - var json = JSON.parse(body); - } catch (err) { - - botkit.debug('JSON Parse error: ', err); + if (err) { + botkit.debug('WEBHOOK ERROR', err); return cb && cb(err); - } - if (json.error) { - botkit.debug('API ERROR', json.error); - return cb && cb(json.error.message); + if (body.error) { + botkit.debug('API ERROR', body.error); + return cb && cb(body.error.message); } botkit.debug('WEBHOOK SUCCESS', body); cb && cb(null, body); - }).form(facebook_message); + }) }; bot.reply = function(src, resp, cb) {