class Stealth::Services::Smooch::Setup

Public Class Methods

trigger() click to toggle source
# File lib/stealth/services/smooch/setup.rb, line 13
def trigger
  SmoochApi.configure do |config|
    config.api_key['Authorization'] = Stealth.config.smooch.jwt_token
    config.api_key_prefix['Authorization'] = 'Bearer'
  end

  reply_handler = Stealth::Services::Smooch::ReplyHandler.new
  menu = reply_handler.persistent_menu
  Stealth::Services::Smooch::Client.set_persistent_menu(menu)

  if ENV['SMOOCH_ENDPOINT'].present?
    Stealth::Services::Smooch::Client.register_webhooks(endpoint: ENV['SMOOCH_ENDPOINT'])
  else
    puts '[ERROR] Please set SMOOCH_ENDPOINT to the endpoint that will receive Smooch webhooks.'
  end
end