Class: VoicemailsMailbox
- Inherits:
-
ApplicationMailbox
- Object
- ActionMailbox::Base
- ApplicationMailbox
- VoicemailsMailbox
- Defined in:
- app/mailboxes/voicemails_mailbox.rb
Overview
Processes voicemail emails from phone systems (Switchvox PBX or hosted PBX).
Phone systems are configured to email voicemail recordings as WAV attachments.
Email routing:
voicemail@warmlyyours.com → This mailbox (Switchvox, no extension)
voicemail+XXX@warmlyyours.com → This mailbox (XXX = extension number)
Workflow:
- Extract caller info from email headers/body
- Extract WAV attachment
- Create CallRecord with call_outcome: :voicemail
- Match employee by extension (from email recipient or body)
- Match caller to existing Customer/Contact, or create lead_qualify Customer
- Create open Activity assigned to the employee for follow-up
- Queue for transcription
Supported email formats:
Switchvox:
From: "Switchvox" switchvox@warmlyyours.com
Subject: Voicemail from [Caller Name] <[Caller Number]>
Body: Contains VM details (duration, date, mailbox)
Attachment: msg*.wav
Hosted PBX:
Body: "You received a message from (+17043707833). The message is in mailbox 401, ..."
Attachment: .wav file
Constant Summary collapse
- RECIPIENT_FORMAT =
/voicemail(?:\+(\d+))?@/i- MIN_DURATION_SECONDS =
5
Constants inherited from ApplicationMailbox
ApplicationMailbox::DIRECT_FILE_EXTENSIONS, ApplicationMailbox::FETCHABLE_MIME_TYPES, ApplicationMailbox::FETCH_MAX_SIZE, ApplicationMailbox::GDRIVE_FILE_RE, ApplicationMailbox::GDRIVE_OPEN_RE, ApplicationMailbox::MAX_FILENAME_LENGTH
Instance Method Summary collapse
Methods inherited from ApplicationMailbox
#attempt_url_download, #collect_fetchable_urls, #create_activity, #create_communication, #fetch_linked_files, #find_sender_party, #get_resource_id, #inline_or_attachment_part?, #process_attachments, #process_content, #replace_cid_references, #sanitize_attachment_filename
Instance Method Details
#process ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'app/mailboxes/voicemails_mailbox.rb', line 36 def process Rails.logger.info "[VoicemailsMailbox] Processing voicemail email: #{mail.subject}" = = unless Rails.logger.warn "[VoicemailsMailbox] No WAV attachment found in email #{inbound_email.id}" return end if [:duration_secs] && [:duration_secs] < MIN_DURATION_SECONDS Rails.logger.info "[VoicemailsMailbox] Skipping short voicemail (#{[:duration_secs]}s) from #{[:caller_number]}" return end call_record = create_voicemail_record() attach_wav_to_record(call_record, ) create_voicemail_activity(call_record, ) queue_transcription(call_record) Rails.logger.info "[VoicemailsMailbox] Created CallRecord #{call_record.id} for voicemail from #{[:caller_number]}" end |