Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions app/models/pager_tree/integrations/live_call_routing/twilio/v3.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ class LiveCallRouting::Twilio::V3 < Integration
{key: :record_email, type: :string, default: ""},
{key: :banned_phone, type: :string, default: ""},
{key: :dial_pause, type: :integer},
{key: :max_wait_time, type: :integer, default: nil}
{key: :max_wait_time, type: :integer, default: nil},
{key: :skip_resolve_on_hangup, type: :boolean, default: false}
]
store_accessor :options, *OPTIONS.map { |x| x[:key] }.map(&:to_s), prefix: "option"

Expand All @@ -32,6 +33,7 @@ class LiveCallRouting::Twilio::V3 < Integration
validates :option_force_input, inclusion: {in: [true, false]}
validates :option_record, inclusion: {in: [true, false]}
validates :option_send_straight_to_voicemail, inclusion: {in: [true, false]}
validates :option_skip_resolve_on_hangup, inclusion: {in: [true, false]}
validates :option_max_wait_time, numericality: {greater_than_or_equal_to: 30, less_than_or_equal_to: 3600}, allow_nil: true
validate :validate_record_emails

Expand All @@ -45,6 +47,7 @@ class LiveCallRouting::Twilio::V3 < Integration
self.option_send_straight_to_voicemail ||= false
self.option_record_email ||= ""
self.option_banned_phone ||= ""
self.option_skip_resolve_on_hangup ||= false
end

SPEAK_OPTIONS = {
Expand Down Expand Up @@ -439,7 +442,7 @@ def adapter_process_queue_status_deferred
if queue_result == "hangup"
self.adapter_alert = alerts.find_by(thirdparty_id: _thirdparty_id)
adapter_alert.logs.create!(message: "Caller hungup while waiting in queue.")
adapter_alert.resolve!(self, force: true)
adapter_alert.resolve!(self, force: true) unless option_skip_resolve_on_hangup
queue_destroy
Comment on lines 442 to 446
end

Expand All @@ -454,8 +457,12 @@ def adapter_process_call_status_deferred
self.adapter_alert = alerts.find_by(thirdparty_id: _thirdparty_id)

if adapter_alert.present? && adapter_alert.meta["live_call_send_straight_to_voicemail"] == true && !adapter_alert.additional_data.any? { |x| x["label"] == "Voicemail" }
adapter_alert.logs.create!(message: "Caller hung up without leaving a message. Marking alert as resolved.")
adapter_alert.resolve!(self, force: true)
if option_skip_resolve_on_hangup
adapter_alert.logs.create!(message: "Caller hung up without leaving a message.")
else
adapter_alert.logs.create!(message: "Caller hung up without leaving a message. Marking alert as resolved.")
adapter_alert.resolve!(self, force: true)
end
elsif adapter_alert.present? && adapter_alert.meta["live_call_send_straight_to_voicemail"] != true && !adapter_alert.meta["live_call_queue_sid"].present?
adapter_alert.logs.create!(message: "Caller hungup before being put in a queue. Marking alert as resolved.")
adapter_alert.resolve!(self, force: true)
Comment on lines 467 to 468
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,10 @@
<p class="form-hint"><%== t(".option_max_wait_time_hint_html") %></p>
</div>

<div class="form-group group">
<%= form.check_box :option_skip_resolve_on_hangup, class: "form-checkbox" %>
<%= form.label :option_skip_resolve_on_hangup, class: "inline-block" %>
<p class="form-hint md:inline-block"><%== t(".option_skip_resolve_on_hangup_hint_html") %></p>
</div>

</div>
Original file line number Diff line number Diff line change
Expand Up @@ -255,3 +255,12 @@
</dd>
</div>

<div class="sm:col-span-1">
<dt class="text-sm font-medium text-gray-500">
<%= t("activerecord.attributes.pager_tree/integrations/live_call_routing/twilio/v3.option_skip_resolve_on_hangup") %>
</dt>
<dd class="mt-1 text-sm text-gray-900">
<%= render partial: "shared/components/badge_enabled", locals: { enabled: integration.option_skip_resolve_on_hangup } %>
</dd>
</div>

2 changes: 2 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ en:
option_record_emails_list_hint_html: "List of email addresses to notify when a voicemail has been recorded"
option_banned_phones_list_hint_html: "List of phone numbers that are banned from calling the integration"
option_max_wait_time_hint_html: "The maximum amount of time (in seconds) that the caller will wait before transferring the call to the voicemail. If set to nil, it will wait indefinitely."
option_skip_resolve_on_hangup_hint_html: "By default, if a caller hangs up before being connected to an acknowledger, the alert will be automatically resolved. Enabling this option will prevent the alert from being automatically resolved when a caller hangs up."
v3_mailer:
call_recording:
subject: "🎧 Alert #%{tiny_id} - New voicemail from %{from}"
Expand Down Expand Up @@ -274,6 +275,7 @@ en:
option_record_emails_list: "Voicemail Emails"
option_banned_phones_list: "Banned Phones"
option_max_wait_time: "Max Wait Time (seconds)"
option_skip_resolve_on_hangup: "Skip Resolve on Hangup"
"pager_tree/integrations/logic_monitor/v3":
option_access_id: "Logic Monitor Access ID"
option_access_key: "Logic Monitor Access Key"
Expand Down