Skip to content

Fix "Twilio.Exceptions.ApiException: Account not allowed to call" - #1418

Merged
yileicn merged 2 commits into
SciSharp:masterfrom
adenchen123:master
Sep 3, 2026
Merged

Fix "Twilio.Exceptions.ApiException: Account not allowed to call"#1418
yileicn merged 2 commits into
SciSharp:masterfrom
adenchen123:master

Conversation

@adenchen123

Copy link
Copy Markdown
Contributor

No description provided.

aden.chen and others added 2 commits September 3, 2026 11:50
Improve Twilio API error handling in outbound calls

Added `Twilio.Exceptions` namespace and introduced a constant for geo-permission error code `21215`. Wrapped `CallResource.CreateAsync` in a `try-catch` block to handle `ApiException` errors. Specifically, added logging and messaging for geo-permission restrictions to enhance error handling and user feedback.
@qodo-code-review

Copy link
Copy Markdown
Contributor

PR Summary by Qodo

Handle Twilio geo-permission errors for outbound calls

🐞 Bug fix 🕐 Less than 10 minutes

Grey Divider

AI Description

• Detect Twilio geo-permission error 21215 when creating outbound calls.
• Log restricted destinations and return actionable feedback instead of propagating the exception.
Diagram

sequenceDiagram
    participant Handler as Outbound Handler
    participant Twilio as Twilio API
    participant Logger as Logger
    participant Message as Dialog Message
    Handler->>Twilio: Create call
    alt Error 21215
        Twilio-->>Handler: ApiException
        Handler->>Logger: Log warning
        Handler->>Message: Set restriction feedback
    else Call accepted
        Twilio-->>Handler: Return call status
    end
Loading
High-Level Assessment

The targeted exception filter is appropriate because it converts only the known Twilio geo-permission failure into actionable feedback while allowing unrelated API failures to retain their existing behavior. A broad ApiException catch or preflight permission request would either hide unexpected failures or add latency and race conditions.

Files changed (1) +24 / -10

Bug fix (1) +24 / -10
OutboundPhoneCallFn.csHandle Twilio error 21215 during outbound call creation +24/-10

Handle Twilio error 21215 during outbound call creation

• Imports Twilio API exceptions and defines the documented geo-permission error code. Wraps call creation in a filtered catch that logs the restricted destination, sets user-facing feedback, and returns failure instead of propagating the exception.

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

@qodo-code-review

Copy link
Copy Markdown
Contributor

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider

Great, no issues found!

Qodo reviewed your code and found no material issues that require review

Grey Divider

Tip of the day
💡 Did you know, you can add REVIEW.md to your repo root and Qodo follows it on every PR

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

@yileicn

yileicn commented Sep 3, 2026

Copy link
Copy Markdown
Member

reviewed

@yileicn
yileicn merged commit bfa981a into SciSharp:master Sep 3, 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.

2 participants