It’s easy to change your Caller ID (assuming your phone provider doesn’t filter it) in Asterisk using something like Set(CALLERID(name)=blah). This is often used to choose which number to use for an outgoing call if you have multiple on a single SIP or ISDN trunk.
But did you know it’s just as easy to change the Callee ID on an outgoing call, i.e. change what your phone displays during the call? This can be very useful to display on the phone which one of several possible outgoing lines (multiple SIP providers, ISDN, …) was used or at which point in an IVR menu you are at the moment. To do this, use Set(CONNECTEDLINE(name)=blah). Before getting started, set sendrpid = pai in your sip.conf.
To make things easier, I created two macros in my dialplan:
[macro-connectedline-name-number]
exten => s,1,Set(CONNECTEDLINE(name,i)=${ARG1})
exten => s,n,Set(CONNECTEDLINE(number,i)=${ARG2})
exten => s,n,Set(CONNECTEDLINE(pres)=allowed)
[macro-connectedline-name]
exten => s,1,Macro(connectedline-name-number,${ARG1}, ${MACRO_EXTEN})
Now I can do things like
[internal-test]
exten => 101,1,Answer()
exten => 101,n,Macro(connectedline-name,Hello World)
exten => 101,n,Playback(hello-world)
exten => 101,n,Hangup()
in my dialplan (IVR example).
Or how about
[outgoing]
exten => 100,1,Macro(connectedline-name,Mailbox)
exten => 100,n,VoiceMailMain(${CALLERID(num)},s)
exten => _XXX.,n,Macro(connectedline-name,VoIP 1)
exten => _XXX.,n,Dial(SIP/${EXTEN}@voipprovider)
(outgoing line example).
The Asterisk Wiki also has an entire page on Manipulating Party ID Information.
Endlich gefunden! Vielen Dank! Ich hab so lange danach gesucht und erst jetzt finde ich es.
Should not be ‘sendrpid = pai’ instead of ‘setrpid = pai’? There is no such ‘setrpid’ in default Asterisk’s sip.conf?
@kamh: Typo. Fixed. Thanks!
@Michael: no problem!
btw on what kind of sip phones did you test it? I use Snom and it partly works. Only ‘name’ is visible but the ‘num’ is not. But they are properly send in SIP message.
@kamh: I also use Snom phones. Your issue is not specific to the Remote-Party-Id header, but also applies to the normal From header. You can change the display style using the display_method configuration parameter (Preferences – Number Display Style) to specify whether to show name, number or both: http://wiki.snom.com/Settings/display_method .
@Michael, does this change the generated CDR logs (e.g for attended-xfer where multiple legs are concerned)
Pingback: Asterisk: Change number in To header | Michael Kuron's Blog
This is great info! I can confirm that it is working great with our Cisco SPA 514G and Asterisk 11.8.
I have been looking for doing that for quite some time…
Since the connected line information can be sent while a call is connected, you may need to prevent the channel driver from acting on a partial update. The ‘i’ option is used to inhibit the channel driver from sending the changed information immediately.