Asterisk: wrong callerid when doing an attended transfer

Posted by Roy de Boer on 5 December 2009

Tag(s): Artikel

Envision the following situation:

  • Alice calls Infi to speak to Charles.
  • Bob at Infi answers the telephone and transfers the call to Charles.
  • Charles notices the phone ringing, sees Bob's Caller ID and picks up the phone informally ('Hi Bob!'). Bob informs Charles that Alice wants to speak to him.
  • Bob hangs up the telephone and Alice can speak to Charles.

A fairly common situation, if you ask me. Unfortunately, Asterisk (by default) displays the wrong Caller ID to Charles. Namely the Caller ID of Alice instead of Bob.The voip-info wiki page states:

Note The caller ID presented to the person you are trying to transfer the call to is not what you would expect - Asterisk sets your caller ID to be the extension the call originally arrived at which may not be the same as the extension the call was answered at. There doesn't appear to be any way of getting the correct caller ID.

Some people even state this is how it should work. Although the 'f' option in the Dial application looks promising,

f: forces callerid to be set as the extension of the line making/redirecting the outgoing call. For example, some PSTNs don't allow callerids from other extensions than the ones that are assigned to you.

it does not work for me. Finally I resorted to a dirty dial plan hack. I'm not proud of it, but it works and maybe it is useful to you. Adapt your dialplan as follows (extensions.conf):

 
; ... some irrelevant logic to map the three digit extension number to ${DESTINATION} is
; omitted
; Save original Caller ID
exten => _ZXX,n,Set(ORIG_CALLERID=${CALLERID(number)})
; determine if this is a transfer =>
; only set Caller ID when transferring
exten => _ZXX,n,GotoIf($[ "x${TRANSFERERNAME}" = "x" ]?noxfr)
; yes, it is a transfer, cut username out of SIP/username-channel. Something
; like preg_match would be nice, but as far as I could find, there is only REGEX
; to see if a string matches.
; The Caller ID as displayed to Charles is Bob :: number_of_alice
exten => _ZXX,n,Set(CALLERID(all)="${CUT(CUT(TRANSFERERNAME,-,1),/,2)} :: ${ORIG_CALLERID}")
; dial destination
exten => _ZXX,n(noxfr),Dial(${DESTINATION},15,Ttk)

Comments:

Posted by Hendrik van der Ploeg on 8 March 2010, 14:03:
Hoi Roy,

Goed opgelost. Hoe kom je aan de variabele 'transferername'?

Ik draai 1.4.21 en deze is niet build-in volgens mij.
Posted by Roy de Boer on 11 March 2010, 13:03:
Bovenstaande is getest op 1.6, maar TRANSFERERNAME zou ook standaard beschikbaar moeten zijn in Asterisk 1.4, zie bijv. http://www.voip-info.org/wiki/index.php?page=Asterisk+v1.4.

Je kunt ook even kijken of het niet aan de twee CUT's ligt door
exten => _ZXX,n,NoOp(${TRANSFERERNAME})
in je dailplan op te nemen en in de asterisk console te kijken.

Post a comment:

Name:
E-mail*:
Comment:
*optional, will not be published.