Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to generate a URL for chatting with a user in a Facebook page using the page scoped id PSID

We have a chatbot on Facebook Messenger Platform, we want to provide the admins an URL to chat with a specific user, for example: https://facebook.com/<page-id>/u/<user-psid>

Currently when opening a chatting thread in a Facebook page URL is https://www.facebook.com/<page-id>/inbox/?mailbox_id=<page-id>&selected_item_id=<user-id>

when we tried replacing the user-id with the PSID it didn't work.

Is there a way to achieve this? we just want a URL to redirect to Facebook page chatting with a user who already talked to the bot and we have his/her PSID.

like image 709
MMayla Avatar asked Jul 14 '19 18:07

MMayla


2 Answers

You can not go to inbox using PSID. You would need ASID. You can get ASID from PSID by following this process: https://developers.facebook.com/docs/messenger-platform/identity/id-matching/ . After that, you would need read_page_mailboxes permission. It is going to deprecate from December, 2019. Read about it here: https://developers.facebook.com/docs/facebook-login/permissions/

like image 95
Azizul Hakim Avatar answered Oct 22 '22 11:10

Azizul Hakim


Given the PSID, you can use Page conversation API to query the conversations of Page.


GET /v7.0/{page-id}/conversations?user_id={PSID}
Host: graph.facebook.com

This API returns Page conversations and links that you can use to open in your browser:

{
  "data": [
    {
      "id": "t_10523963545045c18",
      "link": "/My-PAGEXXX/inbox/119226229829XXXX/",
      "updated_time": "2020-06-21T23:XX:XX+0000"
    }
  ]
}

Ref: https://developers.facebook.com/docs/graph-api/reference/page/conversations/

like image 35
Jiradeto Avatar answered Oct 22 '22 11:10

Jiradeto