Opt-in

Opt-in webhook is fired for several actions and is generally meant for binding a user in your application. This webhook is fired when:

Opt-in for Send to Messenger

When user presses Send to Messenger button, you will receive following webhook.

{
  "event": "opt_in",
  "timestamp": "2016-10-06T13:42:48Z",
  "data": {
    "channel": {
      "id": "6456078759331238786",
      "type": "facebook_messenger"
    },
    "contact": {
      "id": "6456078781510718339"
    },
    "opt_in": {
      "type": "send_to_messenger",
      "payload": "{{PASS_THROUGH_PARAM}}"
    }
  }
}
ParameterTypeDescription
opt_in.typestringDescribes what type of opt-in this is. In case of Send to Messenger, this will always be send_to_messenger.
opt_in.payloadstringData set in Send to Messenger Button as data-ref attribute.

Opt-in for Checkbox

When user ticks Checkbox plugin, you will receive following webhook.

{
  "event": "opt_in",
  "timestamp": "2016-10-06T13:42:48Z",
  "data": {
    "channel": {
      "id": "6456078759331238786",
      "type": "facebook_messenger"
    },
    "contact": {
      "id": "6456078781510718339",
      "user_ref": "{{YOUR_CUSTOM_USER_REF}}" // set on frontend checkbox plugin
    },
    "opt_in": {
      "type": "checkbox",
      "payload": "{{PASS_THROUGH_PARAM}}"
    }
  }
}
ParameterTypeDescription
contact.user_refstringData that has been set in checkbox plugin user_ref attribute. It is should be uniquely generated string ID (unique for each render).
opt_in.typestringDescribes what type of opt-in this is. In case of Checkbox plugin, this will always be checkbox.
opt_in.payloadstringData that has been set in checkbox plugin ref attribute.

Opt-in for Phone Number Matching

This webhook is sent when a user accepts the message request sent to his phone number using Phone Number Entry Point.

{
  "event": "opt_in",
  "timestamp": "2016-10-06T13:42:48Z",
  "data": {
    "channel": {
      "id": "6456078759331238786",
      "type": "facebook_messenger"
    },
    "contact": {
      "id": "6456078781510718339",
      "phone_number": "15558576309"
    },
    "opt_in": {
      "type": "phone_number"
    }
  }
}
ParameterTypeDescription
contact.phone_numberstringPhone number in E.164 format.
opt_in.typestringDescribes what type of opt-in this is. In case of Phone Number Matching, this will always be phone_number.