On July 29, 2019 we deprecated the Messenger codes endpoint for V4.0 and will be removing it for all versions on October 29, 2019
Starting August 15 2019, The Messenger camera will no longer support scanning Messenger Codes.
As an alternative, we recommend businesses take advantage of the phone's native capabilities to scan QR codes with m.me links. See QR Codes on m.me links
Messenger Codes can be scanned to instantly link the user to your bot, no typing needed. They're great for sticking on fliers, ads, or anywhere in the real world where you want people to try your bot.
You can get a Messenger Code for your Page using the Messenger Code API.
Getting the static Messenger Code is useful if you're running a tool that manages messaging on behalf of many different pages. In such a situation, you might want to request a code on behalf of your client and display it in a prominent place in the UI your customers see.
For a complete list of request properties, see the Messenger Code API reference.
curl -X POST -H "Content-Type: application/json" -d '{ "type": "standard", "image_size": 1000 }' "https://graph.facebook.com/v2.6/me/messenger_codes?access_token=<ACCESS_TOKEN>"
Developers can also arbitrarily generate codes to pass different ref
parameters to the same bot. You might use this to track which codes are getting scanned the most. A bot could even activate different functionality based on which code was scanned. For instance, a restaurant could put a different code on a each table to pass along to the bot where food should be delivered.
You can watch for users scanning parametric codes in the postback and referral webhook events.
For a complete list of request properties, see the Messenger Code API reference.
curl -X POST -H "Content-Type: application/json" -d '{
"type": "standard",
"data": {
"ref":"billboard-ad"
},
"image_size": 1000
}' "https://graph.facebook.com/v2.6/me/messenger_codes?access_token=<ACCESS_TOKEN>"
The Messenger Code API will respond with a URI you can download your Messenger Code at.
This is not a permanent URI; you should download and cache the image as soon as possible.
{
"uri": "<YOUR_CODE_URL_HERE>"
}
To scan a Messenger Code, do the following:
After generating a parametric code, you should watch for the ref
parameter in two places:
If the user is entering the bot for the first time, the postback webhook will be called.
If the user is re-entering the bot by scanning the code, the referral webhook will be called.