Asterisk/FreePBX add Listen/Whisper/Barge facilities to your PABX

A few of our customers wanted a feature to listen to other calls. Asterisk/FreePBX already provides ChanSpy, but the problem with it is that you cannot select what extension to listen to. After some digging around, found a few sites with instructions to get this done.

So here’s what I used to implement this. If you’re using this as it is, make sure that there are no feature codes using *222/*223 & *224.

Add below snippet to extensions_custom.conf. Reload asterisk and you’re good to go. To listen on extension 123, simply dial *222123.

[ext-local-custom]

;listen
exten => _*222x.#,1,Macro(user-callerid,)
exten => _*222x.#,n,Answer
exten => _*222x.#,n,NoCDR
exten => _*222x.#,n,Wait(1)
exten => _*222x.#,n,ChanSpy(sip/${EXTEN:4},q)
exten => _*222x.#,n,Hangup

;whisper
exten => _*223x.#,1,Macro(user-callerid,)
exten => _*223x.#,n,Answer
exten => _*223x.#,n,NoCDR
exten => _*223x.#,n,Wait(1)
exten => _*223x.#,n,ChanSpy(sip/${EXTEN:4},qw)
exten => _*223x.#,n,Hangup

;barge
exten => _*224x.#,1,Macro(user-callerid,)
exten => _*224x.#,n,Answer
exten => _*224x.#,n,NoCDR
exten => _*224x.#,n,Wait(1)
exten => _*224x.#,n,ChanSpy(SIP/${EXTEN:4},qB)
exten => _*224x.#,n,Hangup

 

Now, say there are some extensions that you don’t want to be listened on (ex. a manager), there are few ways to do it. But the simplest method I found is using below context. This needs to be added before the above set.

Here, no one should be able to listen/whisper/barge on extension 5205’s calls. What this code does is if someone tries to do be naughty, it will simply hangup the call.

;blockaccess
exten => _*2225205,1,Macro(user-callerid,)
exten => _*2225205,n,Hangup
exten => _*2235205,1,Macro(user-callerid,)
exten => _*2235205,n,Hangup
exten => _*2245205,1,Macro(user-callerid,)
exten => _*2245205,n,Hangup

Comments

17 responses to “Asterisk/FreePBX add Listen/Whisper/Barge facilities to your PABX”

  1. Richard Welsing Avatar
    Richard Welsing

    HELLO ASANKA,

    very nice post. but i am a newbie here to FREEPBX

    can you please give me the steps to finding the “extensions_custom.conf.” file.

    thanks

    1. asanka Avatar
      asanka

      Hi Richard,

      You can find all asterisk config files under /etc/asterisk/

      Regards,

  2. Ram Martinez Avatar

    GOod day,

    Thank you for this.
    It actually works on our elastix system.

    -Ram Martinez

    1. asanka Avatar
      asanka

      Hi Ram,
      Glad it worked out for you.
      Regards

  3. Thomas Avatar
    Thomas

    I just done this but this is not working, i tell you from starting, first i submit the information in the file “extensions_custom.conf.” as you provide here, then i save after i reload the asterisk, but when i am calling 222(exten number) from my extension, it is saying that “your call cannot completed. please help me more.. should i have to do something in “misc application” in my elastix server?

    1. asanka Avatar
      asanka

      Hi Thomas,

      You need to dial *222(exten number) (star222(exten number)) not just 222(exten number). If you need to set it up that way you would have to remove the * in the context.

      Regards,

  4. enderst Avatar
    enderst

    I get a hangup, in the log i get:
    ‘*2221111’ rejected because extension not found in context ‘from-internal’

    1111 does exist.

    1. asanka Avatar
      asanka

      Hi enderst,

      I’m actually not able to say why it won’t work from this information. I’ve applied this to many installations without any problems (v2.11 and V13).

      Regards

  5. Laura Avatar
    Laura

    Thank you for your post!
    I am getting a fast busy when a manager is trying to listen to one of his agents by dialing *222ext
    Freepbx firmware 6.12.65-20; version 12.0.76.4
    any advice or help- I’m a newbie, please be gentle.

  6. Fernando Avatar
    Fernando

    is there a way to put a password on these? that way when *2222020 is dialed, it requests a pin?

    we tried the following:

    exten => _*222x.#,1,Macro(user-callerid,)
    exten => _*222x.#,n,Authenticate(8888)
    exten => _*222x.#,n,Answer
    exten => _*222x.#,n,NoCDR
    exten => _*222x.#,n,Wait(1)
    exten => _*222x.#,n,ChanSpy(sip/${EXTEN:4},q)
    exten => _*222x.#,n,Hangup

    any suggestions would be appreciated.

    1. Fernando Avatar
      Fernando

      just figured it out NVM! 😀

      1. Telemachos Koumartzakis Avatar
        Telemachos Koumartzakis

        Hi Fernando,
        How to did u figure it out finally?
        Thanks

      2. Ray Avatar
        Ray

        Could you please share what you did for the password?

      3. asanka Avatar
        asanka

        I believe it’s this bit:

        exten => _*222x.#,n,Authenticate(8888)

        You can replace 8888 with the pin you want to use to authenticate.

  7. dreedy Avatar
    dreedy

    We are using the new asterisk 14 and i adapted the script to work with this version of asterisk. But the calls are not going to the right extension sometimes any ideas? Here is the change i have made to the script.

    ;listen
    exten => _*222x.#,1,Macro(user-callerid,)
    exten => _*222x.#,n,Answer
    exten => _*222x.#,n,NoCDR
    exten => _*222x.#,n,Wait(1)
    exten => _*222x.#,n,ChanSpy(PJSIP/${SPYNUM},q)
    exten => _*222x.#,n,Hangup

    ;whisper
    exten => _*223x.#,1,Macro(user-callerid,)
    exten => _*223x.#,n,Answer
    exten => _*223x.#,n,NoCDR
    exten => _*223x.#,n,Wait(1)
    exten => _*223x.#,n,ChanSpy(PJSIP/${SPYNUM},qw)
    exten => _*223x.#,n,Hangup

    ;barge
    exten => _*224x.#,1,Macro(user-callerid,)
    exten => _*224x.#,n,Answer
    exten => _*224x.#,n,NoCDR
    exten => _*224x.#,n,Wait(1)
    exten => _*224x.#,n,ChanSpy(PJSIP/${SPYNUM},qB)
    exten => _*224x.#,n,Hangup

    1. JW Avatar
      JW

      I had the same issue (on version 13)
      replace {SPYNUM} with {EXTEN:4}

      {EXTEN:4} basically means use the numbers after the first four digits
      so if you dial *2245555 – the extension is 5555

      {SPYNUM} refers to a previous line in the code like:
      exten => 556,n,Read(SPYNUM,agent-newlocation)
      exten => 556,n,ChanSpy(SIP/${SPYNUM},q)

  8. Bilal Avatar
    Bilal

    Hi Thanks for great tutorial. i there any way that only certain extension number or numbers can listen, or whisper.
    for example I want only let say 7001 can listen but 7002 can whisper but no other extensions cant perform these actions.
    any idea will be appriciated. thanks..

Leave a Reply

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