recurring_notification_request

Sends a subscription request for recurring notifications in Messenger, which can be: daily, weekly and monthly.

recurring_notification_request(request=Hash)

Platforms

Platform
Supported

Messenger

WhatsApp

Telegram

Usage

On-Demand

user = User.where(platform: :messenger).first
user.notification.recurring_notification_request(
    {
        title: "Want to get daily notifications from us?",
        image_url: "https://previews.123rf.com/images/aquir/aquir1909/aquir190907932/129839413-bot%C3%B3n-de-suscripci%C3%B3n-suscr%C3%ADbete-letrero-rojo-redondeado-suscribir.jpg?fj=1",
        payload: :subscribe,
        frequency: :daily,
        reoptin: true
    }
)
user.notification.send

Reply

class MainContext < Conversation

  def actions

    payload :get_started do
    
      @reply.text "Welcome!"
      @reply.recurring_notification_request(
        {
          title: "Whould you like to receive weekly notifications from us?",
          image_url: "https://previews.123rf.com/images/aquir/aquir1909/aquir190907932/129839413-bot%C3%B3n-de-suscripci%C3%B3n-suscr%C3%ADbete-letrero-rojo-redondeado-suscribir.jpg?fj=1",
          payload: :subscribe,
          frequency: :weekly,
          reoptin: true
        }
      )
    end
    
  end
  
end

request param

Name
Description

title String

Required.

The invitation/request title. The character limit is 65.

image_url String

Optional. The URL of the image to display.

payload String/Symbol

Required. After perms granted/removed event, a postback action block will be called if exists in the context.

frequency Enum

Required. :daily, :weekly or :monthly.

reoptin Boolean

Optional. If true, sends a re opt-in template to the user after the set period for Recurring Notifications ends. By default false

timezone String

Optional. Can be set by Pages which determine when they can send Recurring Notifications after user opt-in. If Pages do not specify a timezone, the default timezone is UTC. Please see the list of valid time zones.

Action Block recurring_notification

To capture the subscription and unsubscription events with this action block.

Subscription Status

The user's subscription status can be verified by calling the messenger_recurring_notification_data() method on the User model.

user = User.where(platform: :messenger).first
user.messenger_recurring_notification_data
=> {:token=>"XXXXXXX", :frecuency=>"daily", :expires_at=>2022-11-21 18:06:31 UTC, :token_status=>"NOT_REFRESHED", :timezone=>"UTC", :status=>:active} 

Sending Notifications

To send a notification using the recurring notification token, just call send_using_token() method instead of send().

user = u = User.where(platform: "messenger").first
user.notification.text "Hello World!"
user.notification.send_using_token()

Learn more about Messenger Recurring Notification in the official documentation.

Last updated