From 21621e4e55d79b9c98c7a4db75e6b6ce51a80275 Mon Sep 17 00:00:00 2001 From: Shawn Jackson Date: Mon, 22 Jun 2026 15:48:33 -0500 Subject: [PATCH] RE1-T117 twilio fix --- .../Controllers/TwilioController.cs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/Web/Resgrid.Web.Services/Controllers/TwilioController.cs b/Web/Resgrid.Web.Services/Controllers/TwilioController.cs index db2ec766..235ec49a 100644 --- a/Web/Resgrid.Web.Services/Controllers/TwilioController.cs +++ b/Web/Resgrid.Web.Services/Controllers/TwilioController.cs @@ -297,9 +297,14 @@ private async System.Threading.Tasks.Task ProcessTextCommandsAsync(TextMessage t // only hit the DB again if the department came from the phone-number lookup path. var profile = userProfile ?? await _userProfileService.GetProfileByMobileNumberAsync(textMessage.Msisdn); - // Diagnostic: no matching user profile for the sender's number means no reply is added. + // No matching user profile for the sender's number: reply so the user knows, rather than + // returning an empty response (pre-refactor behavior). if (profile == null) - Framework.Logging.LogInfo($"[Twilio SMS] DepartmentId={departmentId.Value} sender {textMessage.Msisdn} has no matching user profile; no reply will be sent."); + { + Framework.Logging.LogInfo($"[Twilio SMS] DepartmentId={departmentId.Value} sender {textMessage.Msisdn} has no matching user profile; replying with not-found message."); + messageEvent.Processed = true; + response.Message("Resgrid: We couldn't find a Resgrid user linked to this mobile number. Please add this number to your Resgrid profile to use text commands."); + } if (profile != null) { @@ -517,6 +522,14 @@ private async System.Threading.Tasks.Task ProcessTextCommandsAsync(TextMessage t } } } + else + { + // Department resolved but its plan doesn't include inbound text messaging (only the free + // tier lacks it): reply instead of returning an empty response (pre-refactor behavior). + Framework.Logging.LogInfo($"[Twilio SMS] DepartmentId={departmentId.Value} not authorized for inbound text (plan gate); replying with unsupported message."); + messageEvent.Processed = true; + response.Message("Resgrid: Inbound text messaging isn't available on your department's current plan. Please upgrade to a paid plan to enable text commands."); + } } else if (textMessage.To == Config.NumberProviderConfig.TwilioResgridNumber) // Resgrid master text number {