20

From a lot of searching, I found that using fb-messenger://user-thread/ID can be used to deep link to Messenger and open the existing thread with the passed in FB ID or start a new thread if not existent.

It pops over to Messenger and opens a thread, but the thread is with Facebook User and doesn't actually send. See image below. Clicking Facebook User in the header goes to a detail view with the correct user's image and name.

How do I make this work correctly?

Chris
  • 7,270
  • 19
  • 66
  • 110
  • Please keep in mind that Facebook always changes their schemes from time to time, so make sure you don't give it a critical part in your system. – Dani Sh90 Dec 03 '16 at 15:42
  • Hey Chris, I now this is an old post, but did you ever get this to work? – LilMoke Jan 03 '19 at 20:55

5 Answers5

26

Sorry to bring this back from the dead, but it seems that Facebook Messenger has incorporated Universal Links to quick open the Messenger app.

m.me/$USERNAME

for example: http://m.me/zuck will universally link you to message Zuckerberg.

I played with a couple params, but nothing seemed to prefill the message.

phil-monroe
  • 436
  • 6
  • 4
  • 2
    Anyone know a way of using this with Facebook user IDs instead of usernames? I'm getting "Username was not found" when using this with Facebook IDs :( – owencm Jan 17 '18 at 05:24
17

As WizKid (FB Employee) said here:

...there is no documented way to interact with ... [Messenger] so anything you do may break at any second.

So with that in mind, it sounds like fb-messenger://user-thread/ID has been deprecated. That being said, I decompiled the Facebook Android APK and found a line:

return Uri.parse((new StringBuilder("fb-messenger://user/")).append(Uri.encode(s)).toString());

So from what I can see, it looks like fb-messenger://user-thread/ID has been replaced with fb-messenger://user/ID

There's also a line thats:

return Uri.parse((new StringBuilder("fb-messenger://thread/")).append(Uri.encode(s)).toString());

So fb-messenger://thread/ID may be valid too. ID could be a user or thread ID, I didn't dig deep enough to find out.

EDIT: Current Facebook URL is fb-messenger-public://user-thread/ID

Community
  • 1
  • 1
Parker
  • 8,539
  • 10
  • 69
  • 98
  • Thanks for digging around to provide a thorough answer. Probably not worth it to embed one of these URLs into a production app and risk it breaking at anytime. It's unfortunate that this isn't more open to 3rd party use. Oh well – Chris Aug 17 '15 at 23:18
  • Happy to help, sorry I couldn't give you the answer you were hoping for. If you're building a native app, you may be able to call the app using the new iOS SDK https://developers.facebook.com/docs/messenger/ios – Parker Aug 17 '15 at 23:28
  • Odd. I found that the user-thread version is the only one that opened the actual conversation for me, i.e. `fb-messenger://user-thread/{user_id}` where `user_id` is a numeric id. The `fb-messenger//user/...` version opened messenger but not the conversation. I couldn't get any user or thread id to work with the `fb-messenger://thread/...` form. Desktop and mobile browser equivalents for the user conversation look like `https://www.facebook.com/messages/{user_id}` or `https://m.facebook.com/messages/read/?fbid={user_id}` – patricksurry Mar 23 '16 at 19:27
  • 1
    Current Facebook URL is ```fb-messenger-public://user-thread/ID``` – saltwat5r Mar 07 '17 at 10:59
  • in android every time display facebook user not a correct user account Uri.parse((new StringBuilder("fb-messenger://user/")).append(Uri.encode(use‌​r-id)).toString()); – Maulik Santoki Mar 27 '17 at 10:41
  • 2
    This doesn't work for me as of January 2018. Just links to an empty conversation in messenger. – owencm Jan 17 '18 at 05:47
3

All of this has changed. Facebook released short links to connect with a brand or user's Messenger profile. The way to direct link is http://m.me/PROFILE or PAGE_NAME

If you're building bots, you can also pass in a referral parameter. I've written a bunch about this linking in to Messenger conversations.

jrbedard
  • 3,662
  • 5
  • 30
  • 34
1

If you want to jump to code directly, here it is:

NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"https://m.me/%ld", USER_ID]];
if ([[UIApplication sharedApplication] canOpenURL:url]) {
    [[UIApplication sharedApplication] openURL:url];
}
chengsam
  • 7,315
  • 6
  • 30
  • 38
1

Use fb-messenger-public://user-thread/<ID> I got my ID from the recipient ID in the facebook messenger web hook payload. e.g.

{
    "object": "page",
    "entry": [
        {
            "id": "1163189980393936",
            "time": 1500325170682,
            "messaging": [
                {
                    "sender": {
                        "id": ""
                    },
                    "recipient": {
                        "id": "ID"
                    },
                    "timestamp": 1500325170640,
                    "message": {
                        "mid": "mid.$cAAQh6kd9svBjg56V0FdUllNamImF",
                        "seq": 2888,
                        "text": "..."
                    }
                }
            ]
        }
    ]
}
Aminadav Glickshtein
  • 23,232
  • 12
  • 77
  • 117
Curtis Allen
  • 873
  • 1
  • 6
  • 19