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/555-555-5555@myVOIPprovider,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/555-555-5555@myVOIPprovider,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/555-555-5555@myVOIPprovider,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/555-555-5555@myVOIPprovider,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/555-555-5555@myVOIPprovider,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?

Follow-me is not a native Asterisk feature; it is probably implemented by FreePBX provided dialplan. Please use http://community.freepbx.org/ for peer support in the use of FreePBX.

Your caller ID problems are probably also the result of the FreePBX dialplan.

Variable2 would be ${EXTEN} on a simple, pure Asterisk configuration.

Variable1 would not need to be used - however, more responsible ITSP’s will not pass through the caller ID, because it is not one that they have verified as belonging to you.

Thank you David. I have posted this on FreePBX forum as well without success.

$(EXTEN) would produce 7051; the calling extension. I need to produce the dialed extension so if the caller dialed extension 689, 689 is what is passed. If next he dials 1201, then 1201 is passed.

If ${EXTEN} ends up containing the caller ID, FreePBX did that.

On initial entry to the dialplan, ${EXTEN} contains the called ID. My guess would be that FreePBX hides that somewhere, but, again, the FreePBX forums are the place to ask where.