Sandesh B Suvarna

@b.sandesh

Messenger User Acquisition: How to build Facebook Comment Auto Reply(Private Reply) using nodeJS

Note: This document refers to a feature that was removed after Graph API v2.10.

Part 1: Goto your Facebook app (https://developers.facebook.com/apps)

Part 2: update your facebook messenger code as following:
(https://github.com/fbsamples/messenger-platform-samples)

Important note before copying the code: Don’t private reply to all the comments. Make sure you add some filters else be ready to receive a warning from FB (May suspend your app as well!!!)
app.post('/webhook', function (req, res) {
var data = req.body;
// Make sure this is a page subscription
if (data.object == 'page') {
// Iterate over each entry
data.entry.forEach(function(pageEntry) {
//Newsfeed changes webhook request
if(pageEntry.hasOwnProperty('changes')){
pageEntry.changes.forEach(function(changes){
if(changes.field=="feed" && changes.value.item=="comment" && changes.value.verb=="add"){
var messageData = {
message: "hello"
};

NOTE: Please check below if you are looking out for an open source FB/Twitter Chatbot connector.

More by Sandesh B Suvarna

Topics of interest

More Related Stories