Skip to content

Conversation

@adenchen123
Copy link
Contributor

@adenchen123 adenchen123 commented Nov 4, 2025

PR Type

Enhancement


Description

  • Add support for interrupting welcome message during playback

  • Introduce WelcomeMessageAllowToBeInterrupted parameter to control interruption behavior

  • Conditionally use interruptible or non-interruptible instructions based on agent labels

  • Pass interruption flag through query parameters in outbound call processing


Diagram Walkthrough

flowchart LR
  A["Agent Labels"] -->|Contains WelcomeMessageAllowToBeInterrupted| B["Add Query Parameter"]
  B -->|welcome_message_allow_to_be_interrupted=true| C["TwilioOutboundController"]
  C -->|Check Parameter| D{WelcomeMessageAllowToBeInterrupted?}
  D -->|True| E["ReturnInstructions<br/>Interruptible"]
  D -->|False| F["ReturnNoninterruptedInstructions<br/>Non-interruptible"]
Loading

File Walkthrough

Relevant files
Enhancement
TwilioOutboundController.cs
Conditional welcome message interruption handling               

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

  • Replace unconditional ReturnNoninterruptedInstructions call with
    conditional logic
  • Check WelcomeMessageAllowToBeInterrupted parameter from request
  • Use ReturnInstructions for interruptible mode,
    ReturnNoninterruptedInstructions for non-interruptible mode
+9/-1     
ConversationalVoiceRequest.cs
Add welcome message interruption request parameter             

src/Plugins/BotSharp.Plugin.Twilio/Models/ConversationalVoiceRequest.cs

  • Add new nullable boolean property WelcomeMessageAllowToBeInterrupted
  • Bind parameter from query string with name
    welcome_message_allow_to_be_interrupted
  • Enable clients to specify interruption preference for welcome messages
+3/-0     
OutboundPhoneCallFn.cs
Add interruption flag to outbound call URL                             

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

  • Define constant WelcomeMessageAllowToBeInterrupted for parameter name
  • Check if agent labels contain the interruption flag
  • Append query parameter to process URL when flag is present in agent
    labels
+6/-0     

@qodo-merge-pro
Copy link

qodo-merge-pro bot commented Nov 4, 2025

PR Compliance Guide 🔍

Below is a summary of compliance checks for this PR:

Security Compliance
🔴
Malformed query string

Description: Query parameter concatenation is malformed by using
$"${WelcomeMessageAllowToBeInterrupted}=true" without an '&', likely yielding an invalid
URL and potentially overriding path segments or causing request misrouting.
OutboundPhoneCallFn.cs [110-113]

Referred Code
if (agent.Labels.Contains(WelcomeMessageAllowToBeInterrupted))
{
    processUrl += $"${WelcomeMessageAllowToBeInterrupted}=true";
}
Ticket Compliance
🎫 No ticket provided
  • Create ticket/issue
Codebase Duplication Compliance
Codebase context is not defined

Follow the guide to enable codebase context checks.

Custom Compliance
🟢
Generic: Meaningful Naming and Self-Documenting Code

Objective: Ensure all identifiers clearly express their purpose and intent, making code
self-documenting

Status: Passed

Generic: Secure Error Handling

Objective: To prevent the leakage of sensitive system information through error messages while
providing sufficient detail for internal debugging.

Status: Passed

🔴
Generic: Security-First Input Validation and Data Handling

Objective: Ensure all data inputs are validated, sanitized, and handled securely to prevent
vulnerabilities

Status:
Malformed query param: The code appends the interruption flag using
$"${WelcomeMessageAllowToBeInterrupted}=true" which introduces a leading
'$' into the query and omits the '&', resulting in an invalid
parameter and potential runtime misbehavior.

Referred Code
if (agent.Labels.Contains(WelcomeMessageAllowToBeInterrupted))
{
    processUrl += $"${WelcomeMessageAllowToBeInterrupted}=true";
}
Generic: Comprehensive Audit Trails

Objective: To create a detailed and reliable record of critical system actions for security analysis
and compliance.

Status:
Missing audit log: New logic that changes outbound call behavior based on agent labels and modifies the
process URL is not accompanied by any explicit logging of the decision or resulting
parameters for traceability.

Referred Code
if (agent.Labels.Contains(WelcomeMessageAllowToBeInterrupted))
{
    processUrl += $"${WelcomeMessageAllowToBeInterrupted}=true";
}
Generic: Robust Error Handling and Edge Case Management

Objective: Ensure comprehensive error handling that provides meaningful context and graceful
degradation

Status:
Null handling: The conditional branch defaults to non-interruptible when the query parameter is absent
but does not validate conflicting or malformed inputs, and no error handling/logging is
added around the Twilio response generation.

Referred Code
if (request.WelcomeMessageAllowToBeInterrupted.HasValue && request.WelcomeMessageAllowToBeInterrupted.Value)
{
    response = twilio.ReturnInstructions(instruction);
}
else
{
    response = twilio.ReturnNoninterruptedInstructions(instruction);
}
Generic: Secure Logging Practices

Objective: To ensure logs are useful for debugging and auditing without exposing sensitive
information like PII, PHI, or cardholder data.

Status:
URL construction: The new code appends a query parameter for behavior control to the URL without showing
whether sensitive data may be included elsewhere in the URL or logged; ensure constructed
URLs are not logged with PII.

Referred Code
if (agent.Labels.Contains(WelcomeMessageAllowToBeInterrupted))
{
    processUrl += $"${WelcomeMessageAllowToBeInterrupted}=true";
}
  • Update
Compliance status legend 🟢 - Fully Compliant
🟡 - Partial Compliant
🔴 - Not Compliant
⚪ - Requires Further Human Verification
🏷️ - Compliance label

@qodo-merge-pro
Copy link

qodo-merge-pro bot commented Nov 4, 2025

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Possible issue
Fix incorrect query parameter separator

Replace the incorrect $ separator with & when appending the
WelcomeMessageAllowToBeInterrupted query parameter to the URL.

src/Plugins/BotSharp.Plugin.Twilio/OutboundPhoneCallHandler/Functions/OutboundPhoneCallFn.cs [112]

-processUrl += $"${WelcomeMessageAllowToBeInterrupted}=true";
+processUrl += $"&{WelcomeMessageAllowToBeInterrupted}=true";
  • Apply / Chat
Suggestion importance[1-10]: 9

__

Why: The suggestion correctly identifies a bug where an incorrect separator $ is used instead of & for a URL query parameter, which would break the new feature introduced in the PR.

High
  • Update

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant