Setting a custom caller id during a blind transfer

How can I set a custom caller id during a blind transfer in FreePBX (asterisk)? The following code works in FreePBX with Asterisk 1.8, but not Trixbox with Asterisk 1.6, how do I make it work in Trixbox?

[from-internal-custom]
exten => _x.,1,set(__TRANSFER_CONTEXT=custom-test_transfer)

[custom-test_transfer]
exten => _X.,1,Set(CALLERID(name)=Xfer: ${CALLERID(name)})
include => from-internal-xfer

Open in new window

LVL 2
OAC TechnologyProfessional NerdsAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

jfaubiontxCommented:
Asterisk 1.8 supports diversion headers where 1.6 does not. Add the following code to your /etc/asterisk/extensions_override_freepbx.conf file. Replace the NPANXXXXXX@sipconnect.cbeyond.net with your SIP user info. If your SIP provider supports the diversion header, this should correct your caller ID on outbound transferred calls. This is out of a working Trixbox 2.6.2.3 system. Almost didn't have this since this box is being upgraded to 1.8 tomorrow.

[macro-outbound-callerid]
include => macro-outbound-callerid-custom
exten => s,1,ExecIf($["${CALLINGPRES_SV}" != ""],SetCallerPres,${CALLINGPRES_SV})
exten => s,n,ExecIf($["${REALCALLERIDNUM:1:2}" = ""],Set,REALCALLERIDNUM=${CALLERID(number)})
exten => s,n(start),GotoIf($[ $["${REALCALLERIDNUM}" = ""] | $["${KEEPCID}" != "TRUE"] | $["${OUTKEEPCID_${ARG1}}" = "on"] ]?normcid)
exten => s,n,Set(USEROUTCID=${REALCALLERIDNUM})
exten => s,n,GotoIf($["foo${DB(AMPUSER/${REALCALLERIDNUM}/device)}" = "foo"]?bypass)
exten => s,n(normcid),Set(USEROUTCID=${DB(AMPUSER/${REALCALLERIDNUM}/outboundcid)})
exten => s,n(bypass),Set(EMERGENCYCID=${DB(DEVICE/${REALCALLERIDNUM}/emergency_cid)})
exten => s,n,Set(TRUNKOUTCID=${OUTCID_${ARG1}})
exten => s,n,GotoIf($[ $["${EMERGENCYROUTE:1:2}" = ""] | $["${EMERGENCYCID:1:2}" = ""] ]?trunkcid)
exten => s,n,Set(CALLERID(all)=${EMERGENCYCID})
exten => s,n(exit),MacroExit()
exten => s,n(trunkcid),ExecIf($["${TRUNKOUTCID:1:2}" != ""],Set,CALLERID(all)=${TRUNKOUTCID})
exten => s,n(usercid),ExecIf($["${USEROUTCID:1:2}" != ""],Set,CALLERID(all)=${USEROUTCID})
exten => s,n(usercid),SIPAddHeader(Diversion: <sip:NPANXXXXXX@sipconnect.cbeyond.net>;reason=unconditional)
exten => s,n(hidecid),ExecIf($["${CALLERID(name)}"="hidden"],SetCallerPres,prohib_passed_screen)
; end of [macro-outbound-callerid]

Open in new window

0
OAC TechnologyProfessional NerdsAuthor Commented:
I was thinking more along the lines of sending a transferred call to another internal extension, my code was in extensions_custom.conf. The way I had it, when someone does a blind transfer it hangs up on the caller being transferred.
0
jfaubiontxCommented:
I see. Most people want to set the caller id leaving the box. I've never had to change internally with trixbox.  Trixbox has always handled internal caller id as I expected. What exactly are you trying to accomplish here? What caller id are you expecting?
0
Powerful Yet Easy-to-Use Network Monitoring

Identify excessive bandwidth utilization or unexpected application traffic with SolarWinds Bandwidth Analyzer Pack.

OAC TechnologyProfessional NerdsAuthor Commented:
The customer has DID's set up for each user. They also ring  a group of people when a call comes in on their main line.  Currently when the call comes in on the main line, the CID is prefixed with "MAIN - " to let people know the call is on the main line and the receptionist will most likely answer.  However, when this call is then transferred internally as a blind, the person receiving the call still sees "MAIN -" and the caller ID.  So the person that is having the call transferred to them assumes the call is on the main line and refuses to answer.  We would like to either REMOVE the "MAIN -" on blind transfers or add another prefix of "Xfer:"
0
OAC TechnologyProfessional NerdsAuthor Commented:
Any ideas on this one?

Thanks again
0
jfaubiontxCommented:
You probably want something like the following in extensions_custom.conf:

[from-internal-xfer-custom]
exten => s,1,Macro(user-callerid,)
exten => s,n,Set(_TSTPREFIX=)
exten => s,n,Set(_TSTPREFIX=Main:)
exten => s,n,GotoIf($["${TSTPREFIX}" != "${CALLERID(name):0:${LEN(${TSTPREFIX})}}"]?REPCID)
exten => s,n,Noop(Current TSTPREFIX is ${TSTPREFIX}....stripping from Caller ID)
exten => s,n,Set(CALLERID(name)=${CALLERID(name):${LEN(${TSTPREFIX})}})
exten => s,n,Set(_CDPREFIX=)
exten => s,n(REPCID),Noop(CALLERID(name) is ${CALLERID(name)})
exten => s,n,Set(_CDPREFIX=Xfer:)
exten => s,n,Set(CALLERID(name)=${CDPREFIX}${CALLERID(name)})

Open in new window


This will check to make sure the Main: prefix is set after the caller id macro. This should remove then Main: prefix that you have and replace it with Xfer: only on internally transferred calls. I can't confirm this code yet. We are removing the last of our trixbox systems tonight. However I can put this code into the system and test it tonight before we take the system down.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
OAC TechnologyProfessional NerdsAuthor Commented:
I kind of see what that's doing, but it's still not changing the Main: to Xfer:
Doesn't
exten => s,n,Set(_TSTPREFIX=)
exten => s,n,Set(_TSTPREFIX=Main:)
exten => s,n,GotoIf($["${TSTPREFIX}" != "${CALLERID(name):0:${LEN(${TSTPREFIX})}}"]?REPCID)

Open in new window

set TSTPREFIX, then set it again, then search for it?
also
exten => s,n,Noop(Current TSTPREFIX is ${TSTPREFIX}....stripping from Caller ID)

Open in new window

doesn't seem to get called.
0
jfaubiontxCommented:
The thinking behind the setting of TSTPREFIX twice is a programming habit of always initializing variables with a null before using. Not necessary here but habit. My thought process is to check to see if Main: is in the callerID, if so strip it before putting the Xfer: prefix on. If not then just put on the Xfer: prefix.
Line 5 of my code above is checking to see if the Main: prefix is there. If it isn't (the != ) then the statement is true and we branch to label REPCID. If it is there the the != is not true and we fall through to announce the prefix is there and proceed to strip it from the caller ID before running through to add the Xfer: prefix. I do see a couple of issues here that I missed. Line 8 and 9 should be swapped or line 8 eliminated if preferred. Also instead of "s" we should probably be specifying a pattern for the internal extensions.
I do have to apologize though, we had a last minute change by our provider last night that put us behind on the swap and I did not get to test this on the trixbox system. We will be bringing the box back to the shop tomorrow. I can probably test it this weekend.
0
OAC TechnologyProfessional NerdsAuthor Commented:
I just tried swapping lines 8 and 9, and then realized this context isn't being included by anything else. Should I re-write
[from-internal-custom]
exten => _x.,1,set(__TRANSFER_CONTEXT=custom-test_transfer)

Open in new window

to be
[from-internal-custom]
exten => _x.,1,set(__TRANSFER_CONTEXT=from-internal-xfer-custom)

Open in new window

0
jfaubiontxCommented:
That should get it there.
0
OAC TechnologyProfessional NerdsAuthor Commented:
My code right now is:
[from-internal-custom]
exten => s,1,set(__TRANSFER_CONTEXT=from-internal-xfer-custom)

[from-internal-xfer-custom]
exten => s,1,Macro(user-callerid,)
exten => s,n,Set(_TSTPREFIX=)
exten => s,n,Set(_TSTPREFIX=Main:)
exten => s,n,GotoIf($["${TSTPREFIX}" != "${CALLERID(name):0:${LEN(${TSTPREFIX})}}"]?REPCID)
exten => s,n,Noop(Current TSTPREFIX is ${TSTPREFIX}....stripping from Caller ID)
exten => s,n,Set(CALLERID(name)=${CALLERID(name):${LEN(${TSTPREFIX})}})
exten => s,n(REPCID),Noop(CALLERID(name) is ${CALLERID(name)})
exten => s,n,Set(_CDPREFIX=)
exten => s,n,Set(_CDPREFIX=Xfer:)
exten => s,n,Set(CALLERID(name)=${CDPREFIX}${CALLERID(name)})

Open in new window

And it still doesn't strip the word "Main:" from the caller id, nor does it add "Xfer:" to it. I had to change the "_x." to "s" or it would drop the call as it was transferred.
0
OAC TechnologyProfessional NerdsAuthor Commented:
Have any ideas why I'm having this problem?
0
OAC TechnologyProfessional NerdsAuthor Commented:
Any updates on this one?
0
OAC TechnologyProfessional NerdsAuthor Commented:
I had to change TRANSFER_CONTEXT = from-internal-xfer in extensions_additional.conf to TRANSFER_CONTEXT = from-internal-xfer-custom, then I could use jfaubiontx's code with _X. in place of s as the extension. I also had to add
exten => _X.,n,Dial(Local/${EXTEN}@from-internal,)

Open in new window

to the very end so it would dial the extension.
My final code is
[from-internal-xfer-custom]
exten => _X.,1,noop(Entering from-internal-xfer-custom)
exten => _X.,n,Macro(user-callerid,)
exten => _X.,n,Set(_TSTPREFIX=)
exten => _X.,n,Set(_TSTPREFIX=Main:)
exten => _X.,n,GotoIf($["${TSTPREFIX}" != "${CALLERID(name):0:${LEN(${TSTPREFIX})}}"]?REPCID)
exten => _X.,n,Noop(Current TSTPREFIX is ${TSTPREFIX}....stripping from Caller ID)
exten => _X.,n,Set(CALLERID(name)=${CALLERID(name):${LEN(${TSTPREFIX})}})
exten => _X.,n(REPCID),Noop(CALLERID(name) is ${CALLERID(name)})
exten => _X.,n,Set(_CDPREFIX=)
exten => _X.,n,Set(_CDPREFIX=Xfer:)
exten => _X.,n,Set(CALLERID(name)=${CDPREFIX}${CALLERID(name)})
exten => _X.,n,noop(Doing Transfer(${EXTEN}))
exten => _X.,n,Dial(Local/${EXTEN}@from-internal,)

Open in new window

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Voice Over IP

From novice to tech pro — start learning today.