Link to home
Start Free TrialLog in
Avatar of OAC Technology
OAC TechnologyFlag for United States of America

asked on

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

Avatar of jfaubiontx
jfaubiontx
Flag of United States of America image

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

Avatar of OAC Technology

ASKER

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.
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?
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:"
Any ideas on this one?

Thanks again
ASKER CERTIFIED SOLUTION
Avatar of jfaubiontx
jfaubiontx
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.
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.
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

That should get it there.
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.
Have any ideas why I'm having this problem?
Any updates on this one?
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