recurring_notification_request
Sends a subscription request for recurring notifications in Messenger, which can be: daily, weekly and monthly.
Last updated
Was this helpful?
Sends a subscription request for recurring notifications in Messenger, which can be: daily, weekly and monthly.
Last updated
Was this helpful?
Was this helpful?
recurring_notification_request(request=Hash)
Messenger
Telegram
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
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
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.
recurring_notification
To capture the subscription and unsubscription events with this action block.
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}
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()