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

2

6

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.

Elvia answered 14/7, 2019 at 18:46 Comment(0)
B
2

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/

Bottali answered 21/7, 2019 at 7:25 Comment(1)
Do you know an alternative to this? I have discovered about ASID/PSID conversion, but I need something that will not going to deprecate. Thanks AzizulElvia
M
2

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/

Miltie answered 22/6, 2020 at 0:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.