Skip to main content

Submitting parameters

tip
Facebook allows you not only to create a link to the chatbot but also to pass any parameters in the link.

You can use these parameters to track links posted in different sources, to direct users to personalized content or features that a chatbot offers.

A link with a parameter looks as follows:

http://m.me/<PAGE_NAME>?ref=<REF_PARAM>

Requirements:

  • The ref parameter should contain 2083 characters max.
  • For new dialogs, the chatbot should have a Start button.
  • To receive the ref parameter for all users, the page to which the chatbot is connected must be published. Exception: users who have the developer or administrator role in your bot.

How to use

  1. If a user has not yet communicated with the bot, the Start button is displayed. After the dialog starts, the ref parameter becomes available as $request.rawRequest.postback.referral.ref.

  2. If the user has already communicated with the bot, event: rawRequestEvent is sent to the script when the link is clicked. The ref parameter is available as $request.rawRequest.referral.ref

caution
To have the event: rawRequestEvent event passed to the script, specify the receipt of messaging_referrals in Messenger > Settings > Webhooks.

A sample script:

theme: /
state: Example
q!: *
a: Message: {{ $request.rawRequest.postback.referral.ref }} // see item 1

state: OPEN_THREAD || noContext = true
event: rawRequestEvent
a: Event: {{ $request.rawRequest.referral.ref }} // see item 2

If you need to pass several ref parameters, separate them with - . _ ~ symbols not reserved for URIs, for example:

http://m.me/bot?ref=utm_source=vk-utm_medium=post-utm_campaign=bot