i'm creating a registration code for users to a facebook messenger bot i am writing. instead of asking them to open a chat with my bot, and type in the registration code, i would like to provide them a link that will open their facebook messenger on a chat window with my bot, and send the registration code automatically.
i saw a link that opens the chat window (https://m.facebook.com/messages/compose?ids=USER_ID) but can't get it to send a message too.
if you know how to do that, or have an alternative suggestion, i would appreciate the help.
Check out the new referral webhook-reference. It gives you a way to link users directly to your bot with support for passing arbitrary parameters via the link.
So a possible approach would be:
messaging_referral
event.m.me
link to include the registration code in the ref
param e.g http://m.me/mybot?ref=REGISTRATION_CODE
. if you're interested in security you might consider encrypting the codemessaging_referral
event at your webhook with a payload similar to{
"sender":{
"id":"USER_ID"
},
"recipient":{
"id":"PAGE_ID"
},
"timestamp":1458692752478,
"referral": {
"ref": "REGISTRATION_CODE",
"source": "SHORTLINK",
"type": "OPEN_THREAD",
}
}
ref
value and send your desired feedback to the user.