Search code examples
botframeworkbroadcastfacebook-messengermessengerproactive

Interval of hours or days to send proactive message in messenger


What is the range of hours or days that I can send a proactive message to facebook messenger users through botframework?

NodeJS SDK - botbuilder version 3.14

I'm using code sample below

// send simple notification
function sendProactiveMessage(address) {
  var msg = new builder.Message().address(address);
  msg.text('Hello, this is a notification');
  msg.textLocale('en-US');
  bot.send(msg);
}

var savedAddress;
server.post('/api/messages', connector.listen());

// Do GET this endpoint to delivey a notification
server.get('/api/CustomWebApi', (req, res, next) => {
    sendProactiveMessage(savedAddress);
    res.send('triggered');
    next();
  }
);

// root dialog
bot.dialog('/', function(session, args) {

  savedAddress = session.message.address;

  var message = 'Hello! In a few seconds I\'ll send you a message proactively to demonstrate how bots can initiate messages.';
  session.send(message);

  message = 'You can also make me send a message by accessing: ';
  message += 'http://localhost:' + server.address().port + '/api/CustomWebApi';
  session.send(message);

  setTimeout(() => {
   sendProactiveMessage(savedAddress);
  }, 5000);
});

Solution

  • Quoting Facebook Messenger Policy:

    24-Hour Messaging Window

    Businesses and developers using the Send API have up to 24 hours to respond to a message sent by a person in Messenger when using standard messaging. A bot may also send one additional message after the 24-hour time limit has expired. The 24-hour limit is refreshed each time a person responds to a business through one of the eligible actions listed in Messenger Conversation Entry Points. This is commonly referred to as the '24 + 1 policy'.

    For information on how you may be able to send messages outside the 24-hour messaging window, see the Tags documentation, and Sponsored Messages.

    This policy is available here: https://developers.facebook.com/docs/messenger-platform/policy/policy-overview#standard_messaging