Sagee Ben-Zedeff
Sagee Ben-Zedeff

Reputation: 31

Is there a way to pass parameters to a m.me/username URL?

I want to call my FB messenger bot from 2 different web pages, with 2 different contexts. Is there a way to pass this data to the bot so that this can be used in the conversation? The user is not logged in to Facebook when he clicks the m.me link.

Upvotes: 2

Views: 3965

Answers (2)

David
David

Reputation: 137

There is a way to do this, see Passing Parameters via M.me Links:

A m.me link with an added parameter looks like this: http://m.me/mybot?ref=myparam

The value of the ref parameter will be passed to the server via webhook.

Upvotes: 0

ajimix
ajimix

Reputation: 992

As far as I know, the only possibility is to use the "Send to Messenger" plugin where you create a button on your page with a parameter that gets send to your server and then you can redirect the user to your messenger url.

Here you have the documentation: https://developers.facebook.com/docs/messenger-platform/plugin-reference/send-to-messenger

First you need to add the parameter to the button:

<div class="fb-send-to-messenger"
  messenger_app_id="XXX"
  page_id="XXX"
  data-ref="put the parameter here. Max length is 150"
  color="blue"
  size="standard">
</div>

Then you can listen to the event to redirect the user to your bot:

FB.Event.subscribe('send_to_messenger', function(e) {
  window.location.href = 'https://m.me/your-messenger-url';
});

So when users click on the button, your bot server receives the parameter and you can save it for later usage in your conversation.

Upvotes: 1

Related Questions