From c353843da7b40dd579f7d8431871e20d4f2964fe Mon Sep 17 00:00:00 2001 From: Austin Miller Date: Mon, 25 May 2026 08:41:45 -0700 Subject: [PATCH] Adding the option to skip resolve on hangup --- .../integrations/live_call_routing/twilio/v3.rb | 15 +++++++++++---- .../twilio/v3/_form_options.html.erb | 6 ++++++ .../twilio/v3/_show_options.html.erb | 9 +++++++++ config/locales/en.yml | 2 ++ 4 files changed, 28 insertions(+), 4 deletions(-) diff --git a/app/models/pager_tree/integrations/live_call_routing/twilio/v3.rb b/app/models/pager_tree/integrations/live_call_routing/twilio/v3.rb index 1fd0339..629141c 100644 --- a/app/models/pager_tree/integrations/live_call_routing/twilio/v3.rb +++ b/app/models/pager_tree/integrations/live_call_routing/twilio/v3.rb @@ -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" @@ -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 @@ -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 = { @@ -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 end @@ -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) diff --git a/app/views/pager_tree/integrations/live_call_routing/twilio/v3/_form_options.html.erb b/app/views/pager_tree/integrations/live_call_routing/twilio/v3/_form_options.html.erb index b51b412..a84d0df 100644 --- a/app/views/pager_tree/integrations/live_call_routing/twilio/v3/_form_options.html.erb +++ b/app/views/pager_tree/integrations/live_call_routing/twilio/v3/_form_options.html.erb @@ -112,4 +112,10 @@

<%== t(".option_max_wait_time_hint_html") %>

+
+ <%= form.check_box :option_skip_resolve_on_hangup, class: "form-checkbox" %> + <%= form.label :option_skip_resolve_on_hangup, class: "inline-block" %> +

<%== t(".option_skip_resolve_on_hangup_hint_html") %>

+
+ \ No newline at end of file diff --git a/app/views/pager_tree/integrations/live_call_routing/twilio/v3/_show_options.html.erb b/app/views/pager_tree/integrations/live_call_routing/twilio/v3/_show_options.html.erb index 9ecc125..ea02a0d 100644 --- a/app/views/pager_tree/integrations/live_call_routing/twilio/v3/_show_options.html.erb +++ b/app/views/pager_tree/integrations/live_call_routing/twilio/v3/_show_options.html.erb @@ -255,3 +255,12 @@ +
+
+ <%= t("activerecord.attributes.pager_tree/integrations/live_call_routing/twilio/v3.option_skip_resolve_on_hangup") %> +
+
+ <%= render partial: "shared/components/badge_enabled", locals: { enabled: integration.option_skip_resolve_on_hangup } %> +
+
+ diff --git a/config/locales/en.yml b/config/locales/en.yml index 6ddce1a..b3e99a0 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -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}" @@ -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"