Scheduled Messages
Schedule and send messages in the future.
Platform | Supported |
---|---|
Messenger | |
WhatsApp | |
Telegram |
user = User.first
user.notification.text "You'll receive this after 1 minute"
user.notification.scheduled(Time.now + 1.minute)
users = User.all
users.each do |user|
user.notification.text "This is an important announcement"
user.notification.template "main/announcement", {announcement_id: 1}
user.notification.scheduled(Date.tomorrow.to_time)
end
@reply.text "This is a reminder"
@reply.text "Take the cookies out of the oven"
@reply.scheduled(Time.now + 30.minutes)
Name | Description |
---|---|
send_at
Time | Required. The date and time when message(s) will be sent. |
tag
Symbol | Optional.
Scheduled message identification tag, can be any symbol. |
To send scheduled messages, there is a process that must be running. It can be started as follows:
kogno scheduled_messages start
kogno scheduled_messages fg
kogno start
Kogno 1.0.0 server starting in production
Http: starting daemon..
Sequence: starting daemon..
Scheduled Messages: starting daemon..
If the tag argument has been included in the creation of a scheduled message, as the example bellow:
user = User.first
user.notification.text "This is a 24 hours reminder."
user.notification.scheduled(Time.now + 24.hours, :window_24h)
Then the following methods of the
User
model can be called:Deletes the scheduled message associated with the provided tag.
@user.destroy_scheduled_messages(:window_24h)
Re-Schedule the messages associated with the provided tag.
@user.reschedule_scheduled_message(:window_24h, Time.now + 23.hours + 55.minutes)
Checks if there is a scheduled message associated with the provided tag.
@user.scheduled_message?(:window_24h)
Last modified 8mo ago