module Bobot::Event::Common
Common
attributes for all incoming data from Facebook.
Attributes
messaging[R]
page[R]
Public Class Methods
new(messaging)
click to toggle source
# File lib/bobot/events/common.rb, line 7 def initialize(messaging) @messaging = messaging end
Public Instance Methods
mark_as_seen(messaging_options: nil)
click to toggle source
# File lib/bobot/events/common.rb, line 48 def mark_as_seen(messaging_options: nil) page.mark_as_seen(to: sender["id"], messaging_options: messaging_options) end
prior_message()
click to toggle source
If the user responds to your message, the appropriate event (messages, messaging_postbacks, etc.) will be sent to your webhook, with a prior_message
object appended. The prior_message
object includes the source of the message the user is responding to, as well as the user_ref used for the original message send.
# File lib/bobot/events/common.rb, line 24 def prior_message @messaging['prior_message'] end
recipient()
click to toggle source
# File lib/bobot/events/common.rb, line 15 def recipient @messaging[is_a?(Bobot::Event::MessageEcho) ? 'sender' : 'recipient'] end
reply(payload_message:, messaging_options: nil)
click to toggle source
# File lib/bobot/events/common.rb, line 52 def reply(payload_message:, messaging_options: nil) page.send(payload_message: payload_message, to: sender["id"], messaging_options: messaging_options) end
reply_with_attachment(url:, type:, messaging_options: nil)
click to toggle source
# File lib/bobot/events/common.rb, line 64 def reply_with_attachment(url:, type:, messaging_options: nil) page.send_attachment(url: url, type: type, to: sender["id"], messaging_options: messaging_options) end
reply_with_audio(url:, messaging_options: nil)
click to toggle source
# File lib/bobot/events/common.rb, line 72 def reply_with_audio(url:, messaging_options: nil) page.send_audio(url: url, to: sender["id"], messaging_options: messaging_options) end
reply_with_carousel(elements:, image_aspect_ratio: 'square', messaging_options: nil)
Alias for: reply_with_generic
reply_with_file(url:, messaging_options: nil)
click to toggle source
# File lib/bobot/events/common.rb, line 80 def reply_with_file(url:, messaging_options: nil) page.send_file(url: url, to: sender["id"], messaging_options: messaging_options) end
reply_with_generic(elements:, image_aspect_ratio: 'square', messaging_options: nil)
click to toggle source
# File lib/bobot/events/common.rb, line 92 def reply_with_generic(elements:, image_aspect_ratio: 'square', messaging_options: nil) page.send_generic(elements: elements, image_aspect_ratio: image_aspect_ratio, to: sender["id"], messaging_options: messaging_options) end
Also aliased as: reply_with_carousel
reply_with_image(url:, messaging_options: nil)
click to toggle source
# File lib/bobot/events/common.rb, line 68 def reply_with_image(url:, messaging_options: nil) page.send_image(url: url, to: sender["id"], messaging_options: messaging_options) end
reply_with_quick_replies(text:, quick_replies:, messaging_options: nil)
click to toggle source
# File lib/bobot/events/common.rb, line 84 def reply_with_quick_replies(text:, quick_replies:, messaging_options: nil) page.send_quick_replies(text: text, quick_replies: quick_replies, to: sender["id"], messaging_options: messaging_options) end
reply_with_text(text:, messaging_options: nil)
click to toggle source
# File lib/bobot/events/common.rb, line 56 def reply_with_text(text:, messaging_options: nil) page.send_text(text: text, to: sender["id"], messaging_options: messaging_options) end
reply_with_video(url:, messaging_options: nil)
click to toggle source
# File lib/bobot/events/common.rb, line 76 def reply_with_video(url:, messaging_options: nil) page.send_video(url: url, to: sender["id"], messaging_options: messaging_options) end
reply_with_youtube_video(url:, messaging_options: nil)
click to toggle source
# File lib/bobot/events/common.rb, line 60 def reply_with_youtube_video(url:, messaging_options: nil) page.send_youtube_video(url: url, to: sender["id"], messaging_options: messaging_options) end
send_pass_thread_control(target_app_id:, metadata: nil)
click to toggle source
# File lib/bobot/events/common.rb, line 36 def send_pass_thread_control(target_app_id:, metadata: nil) page.deliver_pass_thread_control(to: sender["id"], metadata: metadata, target_app_id: target_app_id) end
send_take_thread_control(metadata: nil)
click to toggle source
# File lib/bobot/events/common.rb, line 32 def send_take_thread_control(metadata: nil) page.deliver_take_thread_control(to: sender["id"], metadata: metadata) end
sender()
click to toggle source
# File lib/bobot/events/common.rb, line 11 def sender @messaging[is_a?(Bobot::Event::MessageEcho) ? 'recipient' : 'sender'] end
sender_action(sender_action:, messaging_options: nil)
click to toggle source
# File lib/bobot/events/common.rb, line 40 def sender_action(sender_action:, messaging_options: nil) page.sender_action(sender_action: sender_action, to: sender["id"], messaging_options: messaging_options) end
sent_at()
click to toggle source
# File lib/bobot/events/common.rb, line 28 def sent_at Time.zone.at(@messaging['timestamp'] / 1000) end
show_typing(state:, messaging_options: nil)
click to toggle source
# File lib/bobot/events/common.rb, line 44 def show_typing(state:, messaging_options: nil) page.show_typing(state: state, to: sender["id"], messaging_options: messaging_options) end