Search code examples
node.jsfacebook-graph-apiwebhooks

Get facebook userID with sender.id


So here is the change event webhook sends me when my page receives a msg :

 {
 "object":"page",
 "entry":
    [{"id":"718511138248476","time":1470310180982,
        "messaging":
            [{"sender":{"id":"845775748857562"},
            "recipient":{"id":"718511138248476"},
            "timestamp":1470310180901,
            "message":
                {"mid":"mid.1470310180891:612cfb6aead5fca278",
                "seq":468,
                "text":"hello"}
            }]
    }]}

But then how should I know which user is actually sending this message ? Is there some way to get the user facebook ID with sender.id ?

And for the second question : is sender.id always the same or it will be changed ? I mean is it wise to save the sender.id in database for when I'm intending to send a msg to the user later on ?


Solution

  • You can read document here https://developers.facebook.com/docs/messenger-platform/user-profile . But response fields do not have "id".