Transfer calls from PRI to SIP trunk

I would like to use asterisk as a gateway, accepting calls on a PRI and based on the DID, dial that number on my SIP trunk to send the call to another PBX system.

Is this a very comlex bit of code that would need to be created?

Thanks in advance


[your context]

exten => putadidhere,1,Dial(SIP/yourpbx/destination)

or you can do

exten => _X.,1,Dial(SIP/yourpbx/${EXTEN}) replaces exten with whatever the DID was…

is that what you need?

Actually, both of those code examples would work, especially the last one. Thanks for the time, I think I can make that work for my application.

Would you be able to suggest an automatic way to assign the DID to the EXTEN variable?

no need to.

when you put the PRI channels in a context, and a call comes in, it ‘dials’ that number in the context.

the exten _X. will match them- _ signifies that a pattern follows, X matches 1 digit 0-9, and . matches any 0 or more digits. So _X. will match any number that is at least 1 digit long.

The ${EXTEN} variable is one of a handful of (very useful) ones that is set by Asterisk- ${EXTEN} matches whatever extension was dialed. You can also manipulate it using this variable like
exten => _9NXXXXXX,1,Dial(SIP/provider/${EXTEN:1}) (dial 9 and then a 7 digit number, ${EXTEN:1} clips the first digit so the provider just gets the phone number, but i digress…

Anyway the result of my previously posted code was that any call which came into that context would go out again over SIP, dialing the extension that was dialed. In other words it would use the PRI DID as the SIP destination.
You can manipulate that too- say you have your own NXX (123-456 for example) and all the calls come in as only the last 4 digits. You can do:

exten => _X.,1,Dial(SIP/yourotherpbx/1123456${EXTEN})
so if the DID came in as 9999, the sip destination would be 1-123-456-9999.

Hope that helps!

Thanks. Got it working perfectly. Thanks again for the help.