Class: WebhookProcessors::SwitchvoxProcessor

Inherits:
Object
  • Object
show all
Defined in:
app/services/webhook_processors/switchvox_processor.rb

Overview

Processes Switchvox PBX webhook callbacks (Event Triggers).

Currently supports:

  • new_voicemail: Stores voicemail metadata, can correlate with email-delivered audio
  • incoming_call: Future - screen pop, CRM lookup
  • call_hangup: Future - call analytics

The primary voicemail audio retrieval is via email (VoicemailsMailbox),
but this webhook provides:

  1. Faster notification than email
  2. Additional metadata not in email (queue info, extension details)
  3. Fallback if email delivery fails

Examples:

WebhookProcessors::SwitchvoxProcessor.call(webhook_log)

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(webhook_log) ⇒ SwitchvoxProcessor

Returns a new instance of SwitchvoxProcessor.



25
26
27
28
# File 'app/services/webhook_processors/switchvox_processor.rb', line 25

def initialize(webhook_log)
  @webhook_log = webhook_log
  @data = webhook_log.data.with_indifferent_access
end

Class Method Details

.call(webhook_log) ⇒ Object



21
22
23
# File 'app/services/webhook_processors/switchvox_processor.rb', line 21

def self.call(webhook_log)
  new(webhook_log).call
end

Instance Method Details

#callObject



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'app/services/webhook_processors/switchvox_processor.rb', line 30

def call
  case @webhook_log.category
  when 'new_voicemail'
    process_new_voicemail
  when 'checked_voicemail'
    process_checked_voicemail
  when 'incoming_call'
    process_incoming_call
  when 'route_to_extension'
    process_route_to_extension
  when 'call_answered'
    process_call_answered
  when 'call_hangup'
    process_call_hangup
  when 'outgoing_call'
    process_outgoing_call
  when 'agent_login', 'agent_logout'
    process_agent_status_change
  else
    Rails.logger.info "[SwitchvoxProcessor] Unhandled category: #{@webhook_log.category}"
    { status: 'logged', category: @webhook_log.category }
  end
end