Skip to content

fix issue GTR-13633 - #1463

Merged
yileicn merged 1 commit into
SciSharp:masterfrom
JackJiang1234:bugfix/drpepper/GTR-13633
Oct 27, 2026
Merged

yileicn merged 1 commit into
SciSharp:masterfrom
JackJiang1234:bugfix/drpepper/GTR-13633

Conversation

@JackJiang1234

Copy link
Copy Markdown
Contributor

No description provided.

@qodo-code-review

qodo-code-review Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Code Review by Qodo

Grey Divider

Sorry, something went wrong

We weren't able to complete the code review on our side. Please try again manually by commenting /agentic_review on this PR.

Grey Divider

Qodo Logo

@qodo-code-review

Copy link
Copy Markdown
Contributor

PR Summary by Qodo

Handle ended Twilio calls during redirects

🐞 Bug fix 🕐 10-20 Minutes

Grey Divider

AI Description

• Handle Twilio's call-not-in-progress error without failing reconnect, hangup, or transfer
 workflows.
• Report an ended call as a failed transfer while treating an already-ended call as hung up.
Diagram

graph TD
  Hook["Reconnect hook"] --> Service["Twilio service"] --> API["Twilio call API"] --> Status{"Call in progress?"}
  Hangup["Hangup function"] --> Service
  Transfer["Transfer function"] --> Service
  Status -->|"Yes"| Redirect["Redirect call"]
  Status -->|"No: 21220"| Skip["Skip redirect"]
Loading
High-Level Assessment

Keep the shared, exception-based redirect helper: it handles the specific Twilio failure consistently while allowing each workflow to decide what an ended call means. Checking call status before redirecting would add a request without eliminating races.

Files changed (4) +38 / -16

Bug fix (4) +38 / -16
TwilioConversationHook.csUse the shared redirect helper for reconnects +2/-5

Use the shared redirect helper for reconnects

• Replaces the direct Twilio call update with the asynchronous service helper after conversation state is saved. An ended call no longer fails the reconnect hook.

src/Plugins/BotSharp.Plugin.Twilio/Hooks/TwilioConversationHook.cs

HangupPhoneCallFn.csAccept already-ended calls during hangup +3/-6

Accept already-ended calls during hangup

• Routes hangup redirects through TwilioService, reusing the instance used for optional ending audio. A call that has already ended is still treated as successfully hung up.

src/Plugins/BotSharp.Plugin.Twilio/OutboundPhoneCallHandler/Functions/HangupPhoneCallFn.cs

TransferPhoneCallFn.csReport transfers that cannot redirect an ended call +7/-5

Report transfers that cannot redirect an ended call

• Uses the shared redirect helper after optional transition-audio generation. If the call has ended, the function returns false and tells the assistant that no transfer occurred.

src/Plugins/BotSharp.Plugin.Twilio/OutboundPhoneCallHandler/Functions/TransferPhoneCallFn.cs

TwilioService.csCentralize asynchronous call redirects and error handling +26/-0

Centralize asynchronous call redirects and error handling

• Adds an asynchronous redirect method that returns false and logs when Twilio reports error 21220. Other Twilio errors continue to propagate.

src/Plugins/BotSharp.Plugin.Twilio/Services/TwilioService.cs

@yileicn

yileicn commented Oct 27, 2026

Copy link
Copy Markdown
Member

reviewed

@yileicn
yileicn merged commit fe8ecbc into SciSharp:master Oct 27, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants