Dynamic inbound-to-outbound routing to a different SIP trunk (V20)

aman-pandey

Trial User
Joined
Aug 21, 2026
Messages
3
Reaction score
0
Hi team,

I'm using Telnyx's API to originate calls into our 3CX (V20, self-hosted). I need these inbound calls to route back out through a different SIP trunk to a phone number that's different each time — not a fixed number.

I've tried using %DialedNum% and %CalledNum% in an Inbound Rule and in a trunk's Default Route ("Forward to Outside Number"), but both get treated as literal text instead of the actual dialed number, and the call fails. Is there a supported way to do this, or do I need to use DISA or a Call Processing Script instead?
 
Can you explain what the aim is in a bit more detail? Are the Outgoing numbers matched 1-to-1 with the Incoming (per-extension forwarding), or do they change over time (CFD or some other automation)?
 
Thanks for looking into this.

To clarify: it's neither. The outgoing number isn't tied 1-to-1 to any extension, and it's not a schedule/time-based change either — it's decided dynamically, per call, by our own backend application before the call is even placed.

Here's the actual flow: our backend calls Telnyx's API to originate a call, specifying a destination number that varies every single time (different number per call, chosen by our application logic). That call lands on 3CX. We then need 3CX to take that same destination number and dial it back out through a different SIP trunk (Twilio in our case).

So essentially: 3CX needs to read "who was this call actually for" from the inbound leg, and re-dial that same number outbound through a specific trunk — with the number being different on every call, not following any fixed pattern or schedule.

Is there a way to access the inbound call's destination number as a true runtime variable (not a static field), either via CFD or another mechanism?
 
And what exactly is the purpose of this?

It looks like a sequence intended to make calls using spoofed Caller IDs, which raises some concerns.

I can help you with this, but could you first explain the purpose of this setup and what you’re trying to achieve? I simply want to make sure I’m not assisting with or enabling any fraudulent use of the system.

Please provide us with a bit more context.
 
Completely understandable, happy to explain.

This is for a technology demonstration/proof-of-concept, not caller ID spoofing. We're a company building on Telnyx's platform, and we're working with Telnyx directly (their MENA/APAC sales and engineering team) to demonstrate a specific capability: Telnyx's Voice API originating a call, routing it through our 3CX PBX, and terminating it via a third-party carrier — with the correct, legitimate CLI (our own verified business number) passed through the whole chain.

The reason we need the destination number to be dynamic rather than fixed: this is meant to prove the routing mechanism works for any destination, not just one hardcoded test number. In our actual production use case, this pattern will be used for a UAE-specific setup where local regulations require call termination through a licensed local carrier rather than Telnyx directly — Twilio is just standing in as a generic third-party trunk for this POC, to prove the architecture before we connect the real local carrier.

The caller ID used throughout is our own legitimate business number (not spoofed) — the concern is purely about correctly routing calls to arbitrary destinations, not disguising who's calling.

Happy to share more context on the business use case if useful, or loop in Telnyx's team directly if that helps confirm this.
 

Forum statistics

Threads
111,875
Messages
589,515
Members
164,724
Latest member
StratisFear