Asterisk: Change Callee-ID using CONNECTEDLINE

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.

9 thoughts on “Asterisk: Change Callee-ID using CONNECTEDLINE

  1. kamh

    Should not be ‘sendrpid = pai’ instead of ‘setrpid = pai’? There is no such ‘setrpid’ in default Asterisk’s sip.conf?

  2. kamh

    @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.

  3. Michael Kuron Post author

    @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 .

  4. din3sh

    @Michael, does this change the generated CDR logs (e.g for attended-xfer where multiple legs are concerned)

  5. Pingback: Asterisk: Change number in To header | Michael Kuron's Blog

  6. Carl

    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…

  7. bonito-kids.ru

    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.

Leave a Reply

Your email address will not be published. Required fields are marked *