2

I wanna create a similar thing, that is described here for my business page on facebook. There are lots of alternatives like chatfuel and manychat, but I wanna have the same Auto PM, but more flexible. What I did so far, I connected to: webhooks and messenger APIs. I wrote these lines of code, which allow me to see all changes in the feed of my Business Page.

app.post("/api/webhooks", jsonParser, (req, res) => {
    const jsonBody = req.body || '';
    if (typeof jsonBody !== 'object' || !jsonBody.entry || jsonBody.object !== 'page') { return res.send('no body'); }
    // else
    const { message, sender_id } = jsonBody.entry[0].changes[0].value;
    console.log(message);
    if (!message) { return res.send('no message'); }
    bot.say(sender_id, 'hey there, Mr. P!');
    return res.send('post request');
});

As I said this piece of code allows me to see, who made changes on my business page, so I can take even user's id. So I thought, if I know user's ID I can send him a message, but I get the error below, when I'm trying to send a message.

{ message: '(#100) No matching user found',
  type: 'OAuthException',
  code: 100,
  error_subcode: 2018001,
  fbtrace_id: 'CkNJQpdP6A9' }

What I'm doing wrong? Do I need maybe more permissions for some actions?

Killuminati
  • 261
  • 2
  • 11
  • You can not message a user, just because they commented on your page. (Your page can reply to their comment in private, though, so that only that particular user will be able to see your reply.) – CBroe Jun 28 '17 at 07:47
  • thanks for your reply, but just tell me how they do this? youtube.com/watch?v=JNGK_0SHXLo – Killuminati Jun 28 '17 at 21:09

1 Answers1

1

Actually, I found how to resolve this thing and it's pretty easy to do. Facebook docs: https://developers.facebook.com/docs/graph-api/reference/v2.9/object/private_replies

Killuminati
  • 261
  • 2
  • 11
  • Is there a way to send a structured message this way ? From what I see, the message object is limited to plain text. I'd like to send a more structured message with call to actions like buttons with postback, and such. Is it possible to send this kind of message with private_replies ? – Majikat Apr 23 '18 at 17:50