From 0858d50a407fc71c0f5e39b7b6847a5db56b1f84 Mon Sep 17 00:00:00 2001 From: "mars.yu" <18671933+yuyixg@users.noreply.github.com> Date: Wed, 18 Nov 2026 15:44:36 +0800 Subject: [PATCH] fix(twilio): answer Twilio's status callbacks with 204 instead of an empty 200 The call status, recording status and transcription callbacks answered with Ok(): a 200 with no body and no content type. Twilio reads that as a failed callback ("Error reading response: Response does not contain content type") and logs warning 15003, "Got HTTP 502 response to .../twilio/voice/status", on every call, though the endpoint ran fine. It wants 204 with no body, or TwiML. Nothing else changes: the callbacks aren't retried and their answer carries nothing. Co-Authored-By: Claude Opus 5.5 --- .../Controllers/TwilioRecordController.cs | 3 ++- .../Controllers/TwilioTranscribeController.cs | 3 ++- .../Controllers/TwilioVoiceController.cs | 4 +++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Plugins/BotSharp.Plugin.Twilio/Controllers/TwilioRecordController.cs b/src/Plugins/BotSharp.Plugin.Twilio/Controllers/TwilioRecordController.cs index dee4e7a67..157f1eabe 100644 --- a/src/Plugins/BotSharp.Plugin.Twilio/Controllers/TwilioRecordController.cs +++ b/src/Plugins/BotSharp.Plugin.Twilio/Controllers/TwilioRecordController.cs @@ -47,6 +47,7 @@ public async Task PhoneRecordingStatus(ConversationalVoiceRequest _logger.LogError($"Unknown record status: {request.CallStatus}, {request.CallSid}"); } - return Ok(); + // 204 and no body, as Twilio wants of a callback (an empty 200 with no content type reads to it as a failure) + return NoContent(); } } diff --git a/src/Plugins/BotSharp.Plugin.Twilio/Controllers/TwilioTranscribeController.cs b/src/Plugins/BotSharp.Plugin.Twilio/Controllers/TwilioTranscribeController.cs index b304953b0..e897ff713 100644 --- a/src/Plugins/BotSharp.Plugin.Twilio/Controllers/TwilioTranscribeController.cs +++ b/src/Plugins/BotSharp.Plugin.Twilio/Controllers/TwilioTranscribeController.cs @@ -58,6 +58,7 @@ await HookEmitter.Emit(_services, async x => await x.OnTranscribe } } - return Ok(); + // 204 and no body, as Twilio wants of a callback (an empty 200 with no content type reads to it as a failure) + return NoContent(); } } diff --git a/src/Plugins/BotSharp.Plugin.Twilio/Controllers/TwilioVoiceController.cs b/src/Plugins/BotSharp.Plugin.Twilio/Controllers/TwilioVoiceController.cs index 5dc53b375..022256783 100644 --- a/src/Plugins/BotSharp.Plugin.Twilio/Controllers/TwilioVoiceController.cs +++ b/src/Plugins/BotSharp.Plugin.Twilio/Controllers/TwilioVoiceController.cs @@ -390,7 +390,9 @@ public async Task PhoneCallStatus(ConversationalVoiceRequest reque break; } - return Ok(); + // Twilio takes an empty 200 with no content type for a failed callback (warning 15003, "Got HTTP 502", on every + // call); it wants 204 and no body, or TwiML + return NoContent(); } protected Dictionary ParseStates(List states)