Custom URI Schemes for the Facebook Messenger

Dev-iL picture Dev-iL · Aug 24, 2014 · Viewed 30k times · Source

Given the recent "encouragement" by Facebook to migrate to a separate messenger app, and as a followup to the {very informative!} answer to the question on URL/URI schemes supported by the Facebook app, I've been wondering whether information regarding the Facebook messenger app custom protocol of fb-messenger:// is available.

The functionality I was looking for was an ability to click a button that would open a FB-messenger chat windows with the user whose numeric Facebook ID is known. This also needed to work if the Facebook app (katana) is not installed on the device (i.e. only the messenger, orca).

I found an example of the desired deep linking (fb-messenger://user-thread/{user-id}), but that didn't seem to work. I realized that FB has a tendency of revising the URIs every once in a while, since these are generally not supposed to be available to the public (as far as I understand).

Answer

Dev-iL picture Dev-iL · Aug 24, 2014

After unsuccessfully searching for this information, I've decided to make a list of my own. Below is what I managed to gather so far, along with a few explanations:

These were taken from version 141.0.0.25.76 (October 21, 2017):

fb-messenger://accounts
fb-messenger://active_now
fb-messenger://addcard
fb-messenger://addmembers
fb-messenger://android_date_time
fb-messenger://android_storage
fb-messenger://autocompose
fb-messenger://autocompose_payment
fb-messenger://bots/get_started/?page_id=%s&cta_id=%s
fb-messenger://business
fb-messenger://business/
fb-messenger://business_extensions
fb-messenger://buy/mc?item_id={#%s}
fb-messenger://callsearch
fb-messenger://commerce/
fb-messenger://compose
fb-messenger://contactmigration
fb-messenger://contacts
fb-messenger://contacts/add_contacts
fb-messenger://contactuploadoptin
fb-messenger://direct_share
fb-messenger://drawoverotherapps
fb-messenger://games
fb-messenger://groupcompose
fb-messenger://groupstab
fb-messenger://groupthreadfbid/
fb-messenger://groupthreadfbid/%s
fb-messenger://ig_contact_import
fb-messenger://installupdate
fb-messenger://instant_article/?article_id=
fb-messenger://instant_article/?article_id=%s
fb-messenger://invite
fb-messenger://join_request
fb-messenger://mai
fb-messenger://messagerequests
fb-messenger://messagesearch
fb-messenger://montage
fb-messenger://montage_composer
fb-messenger://montage_mediapicker
fb-messenger://montageaudiencepicker
fb-messenger://montagecomposer
fb-messenger://networkempathy
fb-messenger://new
fb-messenger://newuser/
fb-messenger://newuser/signup?provider_name=%s&provider_page_fbid=%s
fb-messenger://nfc
fb-messenger://omni_m
fb-messenger://opengrouppreview
fb-messenger://opengrouppreview?group_preview_hash=
fb-messenger://optimistic
fb-messenger://optimistic/%s
fb-messenger://payments
fb-messenger://payments/
fb-messenger://platform
fb-messenger://platform/cta/postback/?cta_id=%s
fb-messenger://platform/share/?cta_id=%s
fb-messenger://ride_map/{%s}
fb-messenger://roomcompose
fb-messenger://rtccall
fb-messenger://sampleflows
fb-messenger://settings
fb-messenger://settings/datasaver
fb-messenger://settings/messengeronlybackup
fb-messenger://settings/montage
fb-messenger://settings/notifications
fb-messenger://settings/people
fb-messenger://settings/phoneevents
fb-messenger://settings/profilepicture
fb-messenger://settings/tincan
fb-messenger://share                    < Used for sharing multimedia, contains 
                                          several extras. See more info below.
fb-messenger://sms
fb-messenger://sms/
fb-messenger://sms/%s
fb-messenger://sms-bridge
fb-messenger://sms-takeover
fb-messenger://sms-takeover/nux?context=%s
fb-messenger://sms-takeover/nux?context=%s&thread_id=%s
fb-messenger://sms-takeover/sms_anonymous_chat_head
fb-messenger://stickerstore
fb-messenger://thread/                  < Deprecated
fb-messenger://threadkeystring
fb-messenger://threads
fb-messenger://threadsettings
fb-messenger://user
fb-messenger://user/
fb-messenger://user/%s                  < Opens chathead/conversation with user %s, where
                                          %s is the numeric fb user id. Using a username 
                                          string here crashes the orca app.
fb-messenger://user/%s?ref=%s&ref_source=%s
fb-messenger://verifyphonenux
fb-messenger://voip
fb-messenger://wave

These are some additions taken from version 293.0.0.13.232 (December 8th 2020):

fb-messenger://carrier_messaging/
fb-messenger://carrier_messaging//%s
fb-messenger://carrier_messaging_group/
fb-messenger://carrier_messaging_group//%s
fb-messenger://dialtone/switch_to_dialtone
fb-messenger://instant_games/play?game_id=
fb-messenger://m.me/
fb-messenger://payments/checkout/?product_type=pages_commerce&product_id=
fb-messenger://payments/paypal_close/
fb-messenger://payments/settings
fb-messenger://paypal_connect_fail/
fb-messenger://paypal_connect_success/
fb-messenger://settings/datasetting
fb-messenger-sametask://instant_games_contact_pick
fb-messenger-sametask://montage_mediapicker
fb-messenger-sametask://share
fb-messenger-sametask://threadsettings
fb-messenger-secure://accounts
fb-messenger-secure://accounts/triggersso
fb-messenger-secure://join_request
fb-messenger-secure://messagerequests
fb-messenger-secure://messagesearch
fb-messenger-secure://notification_to_account_switch
fb-messenger-secure://page_notification_direct_reply
fb-messenger-secure://page_rtc_notification_to_account_switch
fb-messenger-secure://rtccall/audio/%s
fb-messenger-secure://speakeasy_invite_list

Here are some URI schemes whose purpose in this app I don't know:

  • fb:// - see possible URIs of this scheme here.
  • dialtone://
  • fbinternal://
  • fb-messenger-aol://
  • fb-messenger-assistant://
  • fb-messenger-lite://
  • fb-messenger-lite-secure://
  • fb-messenger-public://
  • fb-messenger-secure://
  • fb-work://

Investigation of fb-messenger://share (from older version of this post - may be invalid):

  • Has a StringExtra called ShareType that can be: ShareType.invite, ShareType.forward, ShareType.regular.
  • Has an optional (?) StringExtra called ShareType.invitedUser.
  • Has an optional (?) StringExtra called ShareType.invitedUserDisplayName.
  • Has an optional (?) StringExtra called ShareType.inviteEntryPoint.
  • Has an optional (?) StringExtra called ShareType.invitesSentBroadcastAction.
  • (several others)

In the case of ShareType.forward:

  • Has an Extra with the tag "attachment" OR "message".
  • Has an Extra with the tag "trigger".

###Extra fields of a share Intent (tag : type):###

  • android.intent.extra.TEXT : String
  • attachment : Parcelable
  • message : Parcelable
  • page_name : String
  • page_post_id : String
  • page_target : Long
  • send_as_message_entry_point : String
  • share_attachment_url : String
  • share_caption : String
  • share_description : String
  • share_fbid : String
  • share_link_url : String
  • share_media_url : String
  • share_return_to_fb4a : Boolean
  • share_robotext : String
  • share_story_url : String
  • share_title : String
  • ShareType : String
  • target_recipients : StringArray
  • title : String
  • trigger : String

The required functionality may be achieved by using fb-messenger://user/{user-id} instead of fb-messenger://user-thread/{user-id}.

Note that {user-id} is the user's global numeric ID (e.g. for Zuck it's 4), which can be obtained (as of Nov. 2015) by parsing the html document that corresponds to the person's user name (e.g. for Zuck it's https://www.facebook.com/zuck) and extracting the "entity_id" that is found inside.

According to my latest test, app-scoped user IDs, which are usually the IDs available to developers, do not work for this!

Below is a python3 script that extracts the global ID for a known username (credit: Paul Schreiber):

#!/usr/bin/python

import requests
import re

url = 'https://www.facebook.com/zuck'
idre = re.compile('"entity_id":"([0-9]+)"')
page = requests.get(url)
print(idre.findall(page.content.decode()))

Alternatively, this site can be used to achieve the same thing.

Please also note that this method is not officially supported and might even get your app banned by FB.