Forward extension to extension on another PBX

I have a need at a larger customer to forward an extension on the PIAF system to an extension on the older PBX. This company will run the two PBX’s in parallel for a transition period of time. I first tried using FollowMe with the FollowMe number set as such:
555-555-5555wwwww705
Where 555-555-5555 is the phone number of the old PBX that allows a caller to enter the extension number they wish to reach, each w is a .5 second delay giving the old PBX time to answer, and 705 is the extension to be reached. This did not work as the dialer stops at the w’s…
In looking at the forum, I see someone suggest using Custom Extensions and setting the FollowMe to the Custom Extension. So I configured a Custom Destination 7051 as follows:

;# // BEGIN SSCI 705 DID
exten => 7051,n,Dial(PJSIP/[email protected],D(wwwwww705))
exten => 7051,n,Hangup
;# // END SSCI 705 DID

This actually worked but the caller ID that showed up on the called system was strange in that is was a phone number on the called system. I can adjust the caller ID by the following:

;# // BEGIN SSCI 705 DID
exten => 7051,1,Set(CALLERID(num)=1112223333)
exten => 7051,n,Dial(PJSIP/[email protected],D(wwwwww705))
exten => 7051,n,Hangup
;# // END SSCI 705 DID

where 1112223333 represents the caller ID I want to show up.

Since I expect the caller to come in to the new PBX from an outside number and actually have a receptionist transfer the call to the extension on the old PBX, ideally I would want the caller ID to be passed from the calling outside number t the old PBX. Additionally, since I do not want to have to create custom extensions for each extension on the old system, I would prefer a variable equal to the extension the receptionist is transferring to, to replace the 705. For example:

;# // BEGIN SSCI 705 DID
exten => 7051,1,Set(CALLERID(num)=$Variable1)
exten => 7051,n,Dial(PJSIP/[email protected],D(wwwwww$Variable2))
exten => 7051,n,Hangup
;# // END SSCI 705 DID

Where $Variable1 represents the caller’s CallerID whether it be an outside caller or even a local extension calling an extension on the old system and $Variable2 represents the called extension. I could not make this work as I could not identify the variables I needed. I feel they must exist. It seems the Call Records module must need them. I tried various Asterisk variables like $CALLERID(dnid) but none seem t work. Since I could not get that to work I never even tried to find what I am calling $Variable2 above.

At first I thought because of the strange caller ID I had a programming issue. I changed the programming to use a macro.

;# // BEGIN SSCI 705 DID
exten => 7051,n,Dial(PJSIP/[email protected],M(didconnect))
exten => 7051,n,Hangup
;# // END SSCI 705 DID

; This macro is for dialing the extension on DID capable PBX
[macro-didconnect]
exten => s,1,Wait(3)
exten => s,n,SendDTMF(705)

This works the same as:
exten => 7051,n,Dial(PJSIP/[email protected],D(wwwwww705))

with the same strange caller ID and how I figured out I needed this line:
exten => 7051,1,Set(CALLERID(num)=1112223333)

but it would be much better with the variables. Can anyone help?

One of your questions is easy, in this line

exten => 7051,n,Dial(PJSIP/[email protected],,D(wwwwww705))

The variable ${EXTEN} is equal to the extension or ‘7051’, so you can use this or variations of it for substituting the dialed digits.

The CallerID issue I am not sure about, but you might have success using a dial string like this:

Dial(local/[email protected])

Thanks.
$EXTEN would produce 7051. Right? I am trying to produce the dialed number; in this case 705.

I will try the Dial(local/[email protected])

The goal is to use a single Custom Extension to get to any of the extensions defined on the other PBX.

Yes.

Google ‘asterisk substrings’; you would use ${EXTEN:0:3} to keep the first three characters of ${EXTEN}.

Substring will not work. The goal is to use a single Custom Extension to get to any of the extensions defined on the other PBX. So if the caller dial 689 it would use this same Custom Extension and pass 689 instead of 705. This way I could define all the extensions that exist on the other PBX as extension on the new PBX and the use FollowMe with this single Custom Extension code to connect to the proper extension on the old PBX.

Do you know where the CDR Reports code is. Perhaps if I study that I might see the variable they reference as the dialed number shows in these reports.

This task is not easy, but possible with custom code. This is the type of thing we do in paid support if you have budget. Broad strokes:

  • Create misc application prefix like _#99XXX send to Custom destination
  • custom destination uses custom dial plan to strip #99 and stores remaining digits in channel variable. Send call to outbound-allroutes
  • Create block of code in [macro-dialout-trunk-predial-hook] to check to see of channel variable is populated, and modify the outbound dialstring as appropriate.