How to pass original dialed DID

Running Asterisk 16.16.1 with a SIP trunk connected to a NEC SL2100 PBX. Needing to be able to pass the original dialed DID to the PBX where it can do DID routing. It currently passes the SIP user extension number.



exten => _[+*0-9].,1,Agi(agi://
exten => t,1,Hangup()

include => parkedcalls
include => pbxware-transfer

exten => _[+*0-9].,1,Agi(agi://
exten => t,1,Hangup()

#include trunks-in.conf

You have non-standard code, the AGI script, which you haven’t provided, and which is critical to the question.

Also, DID is not term defined in any SIP specification, it is more a commercial term.

If you had used a minimal, pure dialplan, implementation, what would have been forwarded is the request URI, which is precisely what SIP expects to be used for routing. I suspect you are using a service provider that requires you to register, and therefore can’t use the request URI for the original destination, as that is overridden by the contact URI in the registration.

How provides provide the original destination number in that case varies from provider to provider, although many put it in the To header, which can be extracted and parsed.

In your case you also have to determine how the NEC expects this number to be provided. If you are lucky, it expects it to be in the same form that Asterisk expects, it, namely the request URI, in which case the B side is simple. Setting it in the To header isn’t supported by the currently supported SIP channel driver, so, if it requires that, you have problems.

Thanks for the reply david551, new to configuring asterisk but looking at how to do agi scripts now

If you’re making a call to the PBX over a standard SIP trunk and just need to pass the dialed number…is there a reason you have AGI involved? You can do this in straight dialplan the same as any normal siptrunk:


The ${EXTEN} variable in dialplan is the extension that was called. I’ll admit I have no idea what the NEC expects or behaves in this setup.

However, in any case; you need to pass the dialed extension to any script or external program you may call. There are numerous ways of doing this with AGI.

This is what I meant by:

try this dialplan
exten => _X.,1, NoOP()
exten => _X., n, Dial (SIP/trunknec/${EXTEN})

The OP should not be using chan_sip for new installations.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.