Solved

Setting a custom caller id during a blind transfer

Posted on 2012-03-26
14
2,345 Views
Last Modified: 2012-04-11
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

0
Comment
Question by:DataDudes
  • 9
  • 5
14 Comments
 
LVL 11

Expert Comment

by:jfaubiontx
ID: 37771447
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
 
LVL 2

Author Comment

by:DataDudes
ID: 37771502
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
 
LVL 11

Expert Comment

by:jfaubiontx
ID: 37771702
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
 
LVL 2

Author Comment

by:DataDudes
ID: 37771781
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
 
LVL 2

Author Comment

by:DataDudes
ID: 37777632
Any ideas on this one?

Thanks again
0
 
LVL 11

Accepted Solution

by:
jfaubiontx earned 500 total points
ID: 37778193
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
 
LVL 2

Author Comment

by:DataDudes
ID: 37779234
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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
LVL 11

Expert Comment

by:jfaubiontx
ID: 37782313
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
 
LVL 2

Author Comment

by:DataDudes
ID: 37787803
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
 
LVL 11

Expert Comment

by:jfaubiontx
ID: 37789443
That should get it there.
0
 
LVL 2

Author Comment

by:DataDudes
ID: 37796809
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
 
LVL 2

Author Comment

by:DataDudes
ID: 37803409
Have any ideas why I'm having this problem?
0
 
LVL 2

Author Comment

by:DataDudes
ID: 37823443
Any updates on this one?
0
 
LVL 2

Author Comment

by:DataDudes
ID: 37833907
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

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

What do we know about Legacy Video Conferencing? - Full IT support needed! - Complicated systems at outrageous prices! - Intense training required! Highfive believes we need to embrace a new alternative.
Don’t let your business fall victim to the coming apocalypse – use our Survival Guide for the Fax Apocalypse to identify the risks and signs of zombie fax activities at your business.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now