0

Given 2 facebook pages A and B, with a shared app and bot, I need to be able to forward all messages that the bot receives on page A to page B, in such a way that all moderators on page B can view the messages.

Is this possible? I think the issue lies around where to send messages to on page B. They have to be sent as the bot, and trying to send the message to the page results in a 400 Bad Request. I'm guessing you cant have a message where the sender and recipient is the same.

1 Answers1

0

Your bot can send a message to another Facebook user. The B user must go to the A bot and send a message first. When that message comes to the A bot a number will be associated with the user. The number is unique and not related to other Facebook ids. With that number, the bot can messages the user directly.

There is an example in my demo bot. The bot send a message to my personal account. You can see it live here under the 'Contact' and 'Send a message' links.

Here is some nodejs snippets. The long number is my personal account id for my demo bot.

sendTextMessage(1073962542672604, messageText); // send a message to Matthew directly
...

function sendTextMessage(recipientId, messageText) {
  var messageData = {
    "recipient": {
      "id": recipientId
    },
    "message": {
      "text": messageText,
      "metadata": "DEVELOPER_DEFINED_METADATA"
    }
  };

  callSendAPI(messageData);
}
Matthew Fisher
  • 2,258
  • 2
  • 14
  • 23