Skip to content

fix(twilio): authenticate before loading states in the other Twilio flows - #1482

Merged
yileicn merged 1 commit into
SciSharp:masterfrom
yileicn:master
Nov 5, 2026
Merged

yileicn merged 1 commit into
SciSharp:masterfrom
yileicn:master

Conversation

@yileicn

@yileicn yileicn commented Nov 5, 2026

Copy link
Copy Markdown
Member

The webhook queue and ConversationRelay processor, and the transcribe callback, loaded conversation states without any identity, and the record callback authenticated after loading states, overwriting the identity restored from them. Authenticate first in all three so the session hook's identity is the fallback and state loading can still replace it with the caller's own.

…lows

The webhook queue and ConversationRelay processor, and the transcribe
callback, loaded conversation states without any identity, and the
record callback authenticated after loading states, overwriting the
identity restored from them. Authenticate first in all three so the
session hook's identity is the fallback and state loading can still
replace it with the caller's own.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@qodo-code-review

qodo-code-review Bot commented Nov 5, 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

@yileicn
yileicn merged commit 9b7fa8a into SciSharp:master Nov 5, 2026
3 of 4 checks passed
@qodo-code-review

Copy link
Copy Markdown
Contributor

PR Summary by Qodo

Authenticate Twilio callbacks and caller turns before loading states

🐞 Bug fix 🕐 10-20 Minutes

Grey Divider

AI Description

• Authenticate webhook, ConversationRelay, transcription, and recording flows before conversation
 states load.
• Preserve the authenticated identity as a fallback while allowing stored state to restore the
 caller’s identity.
Diagram

graph TD
  Q["Caller processor"] --> S["Session hook"] --> C["Conversation states"] --> I["Caller identity"]
  T["Transcribe callback"] --> S
  R["Recording callback"] --> H["Status hook"] --> C
Loading
High-Level Assessment

Using the existing Twilio hooks before SetConversationId is the smallest consistent fix across these flows. A separate authentication mechanism would duplicate the hooks without improving identity precedence.

Files changed (3) +18 / -1

Bug fix (3) +18 / -1
TwilioRecordController.csAuthenticate recording callbacks before loading states +3/-1

Authenticate recording callbacks before loading states

• Moves the call-status authentication hook ahead of SetConversationId and SaveStates. A caller identity restored during state loading is no longer overwritten afterward.

src/Plugins/BotSharp.Plugin.Twilio/Controllers/TwilioRecordController.cs

TwilioTranscribeController.csAuthenticate transcription callbacks before loading states +4/-0

Authenticate transcription callbacks before loading states

• Invokes the synchronous session authentication hook before SetConversationId for completed transcriptions with text. The hook supplies a fallback identity that state loading may replace.

src/Plugins/BotSharp.Plugin.Twilio/Controllers/TwilioTranscribeController.cs

TwilioConversationProcessor.csAuthenticate shared caller-message processing +11/-0

Authenticate shared caller-message processing

• Builds an authentication request from the caller message and invokes the session hook before conversation initialization. This covers both webhook-queue and ConversationRelay caller turns.

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

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.

1 participant