Class: Bobot::Page

Inherits:
Object
  • Object
show all
Defined in:
lib/bobot/page.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Page

Returns a new instance of Page.



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/bobot/page.rb', line 5

def initialize(options = {})
  self.slug = options[:slug]
  self.language = options[:language]
  self.page_id = options[:page_id]
  self.page_access_token = options[:page_access_token]
  self.get_started_payload = options[:get_started_payload]
  self.home_url_for_chat_extension = options[:home_url_for_chat_extension]
  self.size_for_chat_extension = options[:size_for_chat_extension]
  self.share_button_for_chat_extension = options[:share_button_for_chat_extension]
  self.in_test_for_chat_extension = options[:in_test_for_chat_extension]
end

Instance Attribute Details

#get_started_payloadObject

Returns the value of attribute get_started_payload.



3
4
5
# File 'lib/bobot/page.rb', line 3

def get_started_payload
  @get_started_payload
end

#home_url_for_chat_extensionObject

Returns the value of attribute home_url_for_chat_extension.



3
4
5
# File 'lib/bobot/page.rb', line 3

def home_url_for_chat_extension
  @home_url_for_chat_extension
end

#in_test_for_chat_extensionObject

Returns the value of attribute in_test_for_chat_extension.



3
4
5
# File 'lib/bobot/page.rb', line 3

def in_test_for_chat_extension
  @in_test_for_chat_extension
end

#languageObject

Returns the value of attribute language.



3
4
5
# File 'lib/bobot/page.rb', line 3

def language
  @language
end

#page_access_tokenObject

Returns the value of attribute page_access_token.



3
4
5
# File 'lib/bobot/page.rb', line 3

def page_access_token
  @page_access_token
end

#page_idObject

Returns the value of attribute page_id.



3
4
5
# File 'lib/bobot/page.rb', line 3

def page_id
  @page_id
end

#share_button_for_chat_extensionObject

Returns the value of attribute share_button_for_chat_extension.



3
4
5
# File 'lib/bobot/page.rb', line 3

def share_button_for_chat_extension
  @share_button_for_chat_extension
end

#size_for_chat_extensionObject

Returns the value of attribute size_for_chat_extension.



3
4
5
# File 'lib/bobot/page.rb', line 3

def size_for_chat_extension
  @size_for_chat_extension
end

#slugObject

Returns the value of attribute slug.



3
4
5
# File 'lib/bobot/page.rb', line 3

def slug
  @slug
end

Class Method Details

.[](value) ⇒ Object



31
32
33
# File 'lib/bobot/page.rb', line 31

def self.[](value)
  find(value) || find_by_slug(value)
end

.find(page_id) ⇒ Object

FINDERS



23
24
25
# File 'lib/bobot/page.rb', line 23

def self.find(page_id)
  Bobot.config.pages.find { |page| page.page_id.to_s == page_id.to_s }
end

.find_by_slug(slug) ⇒ Object



27
28
29
# File 'lib/bobot/page.rb', line 27

def self.find_by_slug(slug)
  Bobot.config.pages.find { |page| page.slug.to_s == slug.to_s }
end

Instance Method Details

#deliver(payload_template:, to:) ⇒ Object



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/bobot/page.rb', line 61

def deliver(payload_template:, to:)
  if payload_template.present?
    if payload_template.key?(:messaging_options) && !payload_template[:messaging_options].nil? && payload_template[:messaging_options].key?(:messaging_type)
      if !%w[RESPONSE UPDATE MESSAGE_TAG].include?(payload_template[:messaging_options][:messaging_type])
        raise Bobot::FieldFormat.new('payload_template[:messaging_options][:messaging_type] is invalid, only "RESPONSE, UPDATE, MESSAGE_TAG" are permitted.', payload_template[:messaging_options][:messaging_type])
      elsif "MESSAGE_TAG" == payload_template[:messaging_options][:messaging_type] && !payload_template[:messaging_options].key?(:tag)
        raise Bobot::FieldFormat.new('payload_template[:messaging_options][:key] is required when messaging_type is MESSAGE_TAG.', payload_template[:messaging_options][:tag])
      end
    end
  else
    raise Bobot::FieldFormat.new('payload_template is required')
  end
  body = { recipient: { id: to }, messaging_type: "RESPONSE" }.merge(payload_template).merge(payload_template[:messaging_options] || {})
  query = { access_token: page_access_token }
  Bobot::Commander.deliver(
    endpoint: '/me/messages',
    body: body,
    query: query,
  )
end

#deliver_pass_thread_control(to:, metadata: nil, target_app_id:) ⇒ Object



51
52
53
54
55
56
57
58
59
# File 'lib/bobot/page.rb', line 51

def deliver_pass_thread_control(to:, metadata: nil, target_app_id:)
  body = { recipient: { id: to }, target_app_id: target_app_id, metadata:  }
  query = { access_token: page_access_token }
  Bobot::Commander.deliver(
    endpoint: '/me/pass_thread_control',
    body: body,
    query: query,
  )
end

#deliver_take_thread_control(to:, metadata: nil) ⇒ Object

REQUESTS



41
42
43
44
45
46
47
48
49
# File 'lib/bobot/page.rb', line 41

def deliver_take_thread_control(to:, metadata: nil)
  body = { recipient: { id: to }, metadata:  }
  query = { access_token: page_access_token }
  Bobot::Commander.deliver(
    endpoint: '/me/take_thread_control',
    body: body,
    query: query,
  )
end

#get_facebook_setupObject



302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
# File 'lib/bobot/page.rb', line 302

def get_facebook_setup
  begin
    puts "- get_whitelist_domains [....]"
    puts get_whitelist_domains.inspect
    puts "- get_whitelist_domains [DONE]"
  rescue => e
    Rails.logger.error(e.message)
  end
  begin
    puts "- get_greeting_text [....]"
    puts get_greeting_text.inspect
    puts "- get_greeting_text [DONE]"
  rescue => e
    Rails.logger.error(e.message)
  end
  begin
    puts "- get_started_button [....]"
    puts get_started_button.inspect
    puts "- get_started_button [DONE]"
  rescue => e
    Rails.logger.error(e.message)
  end
  begin
    puts "- get_persistent_menu [....]"
    puts get_persistent_menu.inspect
    puts "- get_persistent_menu [DONE]"
  rescue => e
    Rails.logger.error(e.message)
  end
  begin
    puts "- get_messenger_extensions_home_url [....]"
    puts get_messenger_extensions_home_url.inspect
    puts "- get_messenger_extensions_home_url [DONE]"
  rescue => e
    Rails.logger.error(e.message)
  end
end

#get_greeting_textObject

Raises:



386
387
388
389
390
391
# File 'lib/bobot/page.rb', line 386

def get_greeting_text
  raise Bobot::FieldFormat.new("access_token is required") unless page_access_token.present?
  Bobot::Profile.get(
    query: { access_token: page_access_token, fields: %w[greeting] },
  )
end

#get_messenger_extensions_home_urlObject

Raises:



547
548
549
550
551
552
# File 'lib/bobot/page.rb', line 547

def get_messenger_extensions_home_url
  raise Bobot::FieldFormat.new("access_token is required") unless page_access_token.present?
  Bobot::Profile.get(
    query: { access_token: page_access_token, fields: %w[home_url] },
  )
end

#get_persistent_menuObject

Raises:



513
514
515
516
517
518
# File 'lib/bobot/page.rb', line 513

def get_persistent_menu
  raise Bobot::FieldFormat.new("access_token is required") unless page_access_token.present?
  Bobot::Profile.get(
    query: { access_token: page_access_token, fields: %w[persistent_menu] },
  )
end

#get_started_buttonObject

Raises:



440
441
442
443
444
445
# File 'lib/bobot/page.rb', line 440

def get_started_button
  raise Bobot::FieldFormat.new("access_token is required") unless page_access_token.present?
  Bobot::Profile.get(
    query: { access_token: page_access_token, fields: %w[get_started] },
  )
end

#get_whitelist_domainsObject

Raises:



413
414
415
416
417
418
# File 'lib/bobot/page.rb', line 413

def get_whitelist_domains
  raise Bobot::FieldFormat.new("access_token is required") unless page_access_token.present?
  Bobot::Profile.get(
    query: { access_token: page_access_token, fields: %w[whitelisted_domains] },
  )
end

#mark_as_seen(to: nil, messaging_options: nil) ⇒ Object



90
91
92
# File 'lib/bobot/page.rb', line 90

def mark_as_seen(to: nil, messaging_options: nil)
  sender_action(sender_action: 'mark_seen', messaging_options: messaging_options, to: to)
end

#send(payload_message:, to: nil, messaging_options: nil) ⇒ Object



94
95
96
# File 'lib/bobot/page.rb', line 94

def send(payload_message:, to: nil, messaging_options: nil)
  deliver(payload_template: { message: payload_message, messaging_options: messaging_options }, to: to)
end

#send_attachment(url:, type:, to: nil, messaging_options: nil) ⇒ Object

Raises:



110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# File 'lib/bobot/page.rb', line 110

def send_attachment(url:, type:, to: nil, messaging_options: nil)
  raise Bobot::FieldFormat.new('url is required') unless url.present?
  raise Bobot::FieldFormat.new('type is required') unless type.present?
  raise Bobot::FieldFormat.new('type is invalid, only "image, audio, video, file" are permitted.', type) unless %w[image audio video file].include?(type)
  send(
    payload_message: {
      attachment: {
        type: type,
        payload: {
          url: url,
        }.tap { |properties| properties.merge!(is_reusable: true) if type == 'image' },
      },
    },
    to: to,
    messaging_options: messaging_options,
  )
end

#send_audio(url:, to: nil, messaging_options: nil) ⇒ Object



152
153
154
# File 'lib/bobot/page.rb', line 152

def send_audio(url:, to: nil, messaging_options: nil)
  send_attachment(url: url, type: 'audio', to: to, messaging_options: messaging_options)
end

#send_buttons(text:, buttons:, to: nil, messaging_options: nil) ⇒ Object

Raises:



179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
# File 'lib/bobot/page.rb', line 179

def send_buttons(text:, buttons:, to: nil, messaging_options: nil)
  raise Bobot::FieldFormat.new('text is required') unless text.present?
  raise Bobot::FieldFormat.new('text size is limited to 640.', "#{text} (#{text.size} chars)") if text.size > 640
  raise Bobot::FieldFormat.new('buttons are required') unless buttons.present?
  raise Bobot::FieldFormat.new('buttons are limited to 3', "#{buttons.size} buttons") if buttons.size > 3
  send(
    payload_message: {
      attachment: {
        type: 'template',
        payload: {
          template_type: 'button',
          text: text,
          buttons: buttons,
        },
      },
    },
    to: to,
    messaging_options: messaging_options,
  )
end

#send_file(url:, to: nil, messaging_options: nil) ⇒ Object



160
161
162
# File 'lib/bobot/page.rb', line 160

def send_file(url:, to: nil, messaging_options: nil)
  send_attachment(url: url, type: 'file', to: to, messaging_options: messaging_options)
end

#send_generic(elements:, image_aspect_ratio: 'square', to: nil, messaging_options: nil) ⇒ Object Also known as: send_carousel

Raises:



200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
# File 'lib/bobot/page.rb', line 200

def send_generic(elements:, image_aspect_ratio: 'square', to: nil, messaging_options: nil)
  raise Bobot::FieldFormat.new('elements are required') if elements.nil?
  raise Bobot::FieldFormat.new('elements are limited to 10.', "#{elements.size} elements") if elements.size > 10
  raise Bobot::FieldFormat.new('image_aspect_ratio is required') if image_aspect_ratio.nil?
  raise Bobot::FieldFormat.new('image_aspect_ratio is invalid, only "square, horizontal" are permitted.', image_aspect_ratio) unless %w[square horizontal].include?(image_aspect_ratio)
  send(
    payload_message: {
      attachment: {
        type: 'template',
        payload: {
          template_type: 'generic',
          image_aspect_ratio: image_aspect_ratio,
          elements: elements,
        },
      },
    },
    to: to,
    messaging_options: messaging_options,
  )
end

#send_image(url:, to: nil, messaging_options: nil) ⇒ Object



148
149
150
# File 'lib/bobot/page.rb', line 148

def send_image(url:, to: nil, messaging_options: nil)
  send_attachment(url: url, type: 'image', to: to, messaging_options: messaging_options)
end

#send_quick_replies(text:, quick_replies:, to: nil, messaging_options: nil) ⇒ Object

Raises:



164
165
166
167
168
169
170
171
172
173
174
175
176
177
# File 'lib/bobot/page.rb', line 164

def send_quick_replies(text:, quick_replies:, to: nil, messaging_options: nil)
  raise Bobot::FieldFormat.new('text is required') unless text.present?
  raise Bobot::FieldFormat.new('text size is limited to 640.', "#{text} (#{text.size} chars)") if text.size > 640
  raise Bobot::FieldFormat.new('quick_replies are required') unless quick_replies.present?
  raise Bobot::FieldFormat.new('quick_replies are limited to 11.', "#{quick_replies.size} quick replies") if quick_replies.size > 11
  send(
    payload_message: {
      text: text,
      quick_replies: quick_replies,
    },
    to: to,
    messaging_options: messaging_options,
  )
end

#send_text(text:, to: nil, messaging_options: nil) ⇒ Object

Raises:



98
99
100
101
102
103
104
105
106
107
108
# File 'lib/bobot/page.rb', line 98

def send_text(text:, to: nil, messaging_options: nil)
  raise Bobot::FieldFormat.new('text is required') unless text.present?
  raise Bobot::FieldFormat.new('text size is limited to 640.', "#{text} (#{text.size} chars)") if text.size > 640
  send(
    payload_message: {
      text: text,
    },
    to: to,
    messaging_options: messaging_options,
  )
end

#send_video(url:, to: nil, messaging_options: nil) ⇒ Object



156
157
158
# File 'lib/bobot/page.rb', line 156

def send_video(url:, to: nil, messaging_options: nil)
  send_attachment(url: url, type: 'video', to: to, messaging_options: messaging_options)
end

#send_youtube_video(url:, to: nil, messaging_options: nil) ⇒ Object

Raises:



128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# File 'lib/bobot/page.rb', line 128

def send_youtube_video(url:, to: nil, messaging_options: nil)
  raise Bobot::FieldFormat.new('url is required') unless url.present?
  raise Bobot::FieldFormat.new('url is not valid', url) unless url =~ %r{^(?:https?:\/\/)?(?:www\.)?youtu(?:\.be|be\.com)\/(?:watch\?v=)?([\w-]{10,})}
  send(
    payload_message: {
      attachment: {
        type: "template",
        payload: {
          template_type: "open_graph",
          elements: [
            { url: url },
          ],
        },
      },
    },
    to: to,
    messaging_options: messaging_options,
  )
end

#sender_action(sender_action:, to: nil, messaging_options: nil) ⇒ Object



82
83
84
# File 'lib/bobot/page.rb', line 82

def sender_action(sender_action:, to: nil, messaging_options: nil)
  deliver(payload_template: { sender_action: sender_action, messaging_options: messaging_options }, to: to)
end

#set_get_started_button!Object

You can define the action to trigger when new humans click on ==

the Get Started button. Before doing it you should check to select the ==

messaging_postbacks field when setting up your webhook. ==

Raises:



423
424
425
426
427
428
429
430
# File 'lib/bobot/page.rb', line 423

def set_get_started_button!
  raise Bobot::FieldFormat.new("access_token is required") unless page_access_token.present?
  raise Bobot::FieldFormat.new("get_started_payload is required") unless get_started_payload.present?
  Bobot::Profile.set(
    body: { get_started: { payload: get_started_payload } },
    query: { access_token: page_access_token },
  )
end

#set_greeting_text!Object

Set bot description (only displayed on first time). ==

Raises:



341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
# File 'lib/bobot/page.rb', line 341

def set_greeting_text!
  raise Bobot::FieldFormat.new("access_token is required") unless page_access_token.present?
  greeting_texts = []
  if self.language.nil?
    # Default text
    short_slug = slug.gsub(/_\w+$/, "")
    greeting_text = I18n.t("bobot.#{slug}.config.greeting_text", locale: I18n.default_locale, default: nil)
    greeting_text = I18n.t("bobot.#{short_slug}.config.greeting_text", locale: I18n.default_locale, default: nil) if greeting_text.nil?
    greeting_texts << { locale: 'default', text: greeting_text } if greeting_text.present?
    # Each languages
    I18n.available_locales.each do |locale|
      greeting_text = I18n.t("bobot.#{slug}.config.greeting_text", locale: locale, default: nil)
      next unless greeting_text.present?
      facebook_locales = I18n.t("bobot.#{slug}.config.facebook_locales", locale: locale, default: [])
      facebook_locales.to_a.each do |locale_long|
        greeting_texts << { locale: locale_long, text: greeting_text }
      end
    end
  else
    short_slug = slug.gsub(/_#{language}$/, "")
    greeting_text = I18n.t("bobot.#{slug}.config.greeting_text", locale: language, default: nil)
    greeting_text = I18n.t("bobot.#{short_slug}.config.greeting_text", locale: language, default: nil) if greeting_text.nil?
    greeting_texts << { locale: 'default', text: greeting_text } if greeting_text.present?
  end
  if greeting_texts.present?
    greeting_texts.each do |row|
      if row[:text].present? && row[:text].size > 160
        raise Bobot::FieldFormat.new("greeting text for locale #{row[:locale]} is limited to 160.", "#{row[:text]} (#{row[:text].size} chars)")
      end
    end
    Bobot::Profile.set(
      body: { greeting: greeting_texts },
      query: { access_token: page_access_token },
    )
  end
end

#set_messenger_extensions_home_url!Object

Set bot home url ==

Allows your bot to enable a Chat Extension in the composer drawer in Messenger. ==

It controls what is displayed when the Chat Extension is invoked via the composer drawer in Messenger. ==

Raises:



523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
# File 'lib/bobot/page.rb', line 523

def set_messenger_extensions_home_url!
  raise Bobot::FieldFormat.new("access_token is required") unless page_access_token.present?
  raise Bobot::FieldFormat.new("home_url_for_chat_extension is required") unless home_url_for_chat_extension.present?
  Bobot::Profile.set(
    body: { 
      "home_url": {
        "url": home_url_for_chat_extension,
        "webview_height_ratio": size_for_chat_extension || "tall",
        "webview_share_button": share_button_for_chat_extension || "show",
        "in_test": !in_test_for_chat_extension.nil? ? in_test_for_chat_extension : true,
      },
    },
    query: { access_token: page_access_token },
  )
end

#set_persistent_menu!Object

You can show a persistent menu to humans. ==

If you want to have a persistent menu, you have to set get_started ==

button before. ==

Raises:



450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
# File 'lib/bobot/page.rb', line 450

def set_persistent_menu!
  raise Bobot::FieldFormat.new("access_token is required") unless page_access_token.present?
  persistent_menus = []
  # Default text
  if language.nil?
    short_slug = slug.gsub(/_\w+$/, "")
    persistent_menu = I18n.t("bobot.#{slug}.config.persistent_menu", locale: I18n.default_locale, default: {})
    persistent_menu = I18n.t("bobot.#{short_slug}.config.persistent_menu", locale: I18n.default_locale, default: {}) unless persistent_menu.present?
    if persistent_menu.present?
      persistent_menus << {
        locale: 'default',
        composer_input_disabled: persistent_menu[:composer_input_disabled],
        call_to_actions: persistent_menu[:call_to_actions],
      }
    end
    # Each languages
    I18n.available_locales.each do |locale|
      persistent_menu = I18n.t("bobot.#{slug}.config.persistent_menu", locale: locale, default: nil)
      persistent_menu = I18n.t("bobot.#{short_slug}.config.persistent_menu", locale: locale, default: nil) if persistent_menu.nil?
      facebook_locales = I18n.t("bobot.#{slug}.config.facebook_locales", locale: locale, default: [])
      facebook_locales = I18n.t("bobot.#{short_slug}.config.facebook_locales", locale: locale, default: []) unless facebook_locales.present?
      next unless persistent_menu.present?
      facebook_locales.to_a.each do |locale_long|
        persistent_menus << {
          locale: locale_long,
          composer_input_disabled: persistent_menu[:composer_input_disabled],
          call_to_actions: persistent_menu[:call_to_actions],
        }
      end
    end
  else
    short_slug = slug.gsub(/_#{language}$/, "")
    persistent_menu = I18n.t("bobot.#{slug}.config.persistent_menu", locale: language, default: {})
    persistent_menu = I18n.t("bobot.#{short_slug}.config.persistent_menu", locale: language, default: {}) unless persistent_menu.present?
    if persistent_menu.present?
      persistent_menus << {
        locale: 'default',
        composer_input_disabled: persistent_menu[:composer_input_disabled],
        call_to_actions: persistent_menu[:call_to_actions],
      }
    end
  end
  if persistent_menus.present?
    persistent_menus.each do |row|
      if row[:title].present? && row[:title].size > 30
        raise Bobot::FieldFormat.new("persistent menu text for locale #{row[:locale]} is limited to 30.", "#{row[:title]} (#{row[:title].size} chars)")
      end
    end
    Bobot::Profile.set(
      body: { persistent_menu: persistent_menus },
      query: { access_token: page_access_token },
    )
  end
end

#set_whitelist_domains!Object

Set bot whitelist domains (only displayed on first time) ==

Some features like Messenger Extensions and Checkbox Plugin require ==

a page to specify a domain whitelist. ==

Raises:



396
397
398
399
400
401
402
403
# File 'lib/bobot/page.rb', line 396

def set_whitelist_domains!
  raise Bobot::FieldFormat.new("access_token is required") unless page_access_token.present?
  raise Bobot::FieldFormat.new("Bobot.config.domains is required") unless Bobot.config.domains.present?
  Bobot::Profile.set(
    body: { whitelisted_domains: Bobot.config.domains },
    query: { access_token: page_access_token },
  )
end

#show_typing(state:, to: nil, messaging_options: nil) ⇒ Object



86
87
88
# File 'lib/bobot/page.rb', line 86

def show_typing(state:, to: nil, messaging_options: nil)
  sender_action(sender_action: (state ? 'typing_on' : 'typing_off'), messaging_options: messaging_options, to: to)
end

#unset_get_started_button!Object

Raises:



432
433
434
435
436
437
438
# File 'lib/bobot/page.rb', line 432

def unset_get_started_button!
  raise Bobot::FieldFormat.new("access_token is required") unless page_access_token.present?
  Bobot::Profile.unset(
    body: { fields: %w[persistent_menu get_started] },
    query: { access_token: page_access_token },
  )
end

#unset_greeting_text!Object

Raises:



378
379
380
381
382
383
384
# File 'lib/bobot/page.rb', line 378

def unset_greeting_text!
  raise Bobot::FieldFormat.new("access_token is required") unless page_access_token.present?
  Bobot::Profile.unset(
    body: { fields: %w[greeting] },
    query: { access_token: page_access_token },
  )
end

#unset_messenger_extensions_home_url!Object

Raises:



539
540
541
542
543
544
545
# File 'lib/bobot/page.rb', line 539

def unset_messenger_extensions_home_url!
  raise Bobot::FieldFormat.new("access_token is required") unless page_access_token.present?
  Bobot::Profile.unset(
    body: { fields: %w[home_url] },
    query: { access_token: page_access_token },
  )
end

#unset_persistent_menu!Object

Raises:



505
506
507
508
509
510
511
# File 'lib/bobot/page.rb', line 505

def unset_persistent_menu!
  raise Bobot::FieldFormat.new("access_token is required") unless page_access_token.present?
  Bobot::Profile.unset(
    body: { fields: %w[persistent_menu] },
    query: { access_token: page_access_token },
  )
end

#unset_whitelist_domains!Object

Raises:



405
406
407
408
409
410
411
# File 'lib/bobot/page.rb', line 405

def unset_whitelist_domains!
  raise Bobot::FieldFormat.new("access_token is required") unless page_access_token.present?
  Bobot::Profile.unset(
    body: { fields: %w[whitelisted_domains] },
    query: { access_token: page_access_token },
  )
end

#update_facebook_setup!Object

SETUP



227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
# File 'lib/bobot/page.rb', line 227

def update_facebook_setup!
  begin
    puts "- unset_whitelist_domains! [....]"
    unset_whitelist_domains!
    puts "- unset_whitelist_domains! [DONE]"
  rescue => e
    Rails.logger.error(e.message)
  end
  begin
    puts "- set_whitelist_domains! [....]"
    set_whitelist_domains!
    puts "- set_whitelist_domains! [DONE]"
  rescue => e
    Rails.logger.error(e.message)
  end
  begin
    puts "- unset_greeting_text! [....]"
    unset_greeting_text!
    puts "- unset_greeting_text! [DONE]"
  rescue => e
    Rails.logger.error(e.message)
  end
  begin
    puts "- set_greeting_text! [....]"
    set_greeting_text!
    puts "- set_greeting_text! [DONE]"
  rescue => e
    Rails.logger.error(e.message)
  end
  begin
    puts "- unset_get_started_button! [....]"
    unset_get_started_button!
    puts "- unset_get_started_button! [DONE]"
  rescue => e
    Rails.logger.error(e.message)
  end
  begin
    puts "- set_get_started_button! [....]"
    set_get_started_button!
    puts "- set_get_started_button! [DONE]"
  rescue => e
    Rails.logger.error(e.message)
  end
  begin
    puts "- unset_persistent_menu! [....]"
    unset_persistent_menu!
    puts "- unset_persistent_menu! [DONE]"
  rescue => e
    Rails.logger.error(e.message)
  end
  begin
    puts "- set_persistent_menu! [....]"
    set_persistent_menu!
    puts "- set_persistent_menu! [DONE]"
  rescue => e
    Rails.logger.error(e.message)
  end
  if home_url_for_chat_extension.present?
    begin
      puts "- unset_messenger_extensions_home_url! [....]"
      unset_messenger_extensions_home_url!
      puts "- unset_messenger_extensions_home_url! [DONE]"
    rescue => e
      Rails.logger.error(e.message)
    end
    begin
      puts "- set_messenger_extensions_home_url! [....]"
      set_messenger_extensions_home_url!
      puts "- set_messenger_extensions_home_url! [DONE]"
    rescue => e
      Rails.logger.error(e.message)
    end
  end
end