Write-up: BLF/Intercom

Helix26404
Posts: 298
Member Since:
2006-06-06

See this thread for background info: http://www.trixbox.org/forums/vendor-moderated-forums/polycom/pos...

Tested with:
Polycom 650s
trixbox 2.3.0.10 (Asterisk 1.4.15 & FreePBX 2.3.1.3)

Objectives/requirements for this environment:

1.) Intercom functionality for every desktop extension. Execs like to hit one button, have their assistant's phone beep, and have a conversation. Likewise, assistants like to hit one button, announce a call to the exec, and transfer it through to him/her.

2.) BLF needed for exec and assistants--they like to look at their phones and see if the other is on the line.

3.) The ability to have #1 & #2, but additionally, allowing regular calls (non-intercom) to be made to each extension, and having BLF monitor these calls, as well as calls made over intercom.

4.) The ability to easily bridge/transfer calls using this setup, doing the best possible to minimize the number of steps involved.

Solution:

1.) How did I make it work? Let's take an example:

Assistant: Ext. 200
Exec: Ext. 201

But before--why is the extra code below necessary? Why not just tell extension 200 to auto-pickup and map the speed-dial button/BLF to extension 200? Because--you don't want calls coming from the outside or somewhere else internally to activate the intercom on the phone if each party isn't expecting it. So, in order to both 1.) get the speed-dials to signal intercom, and 2.) allow normal calls to come in, the phone needs to believe that it is communicating with two separate extensions--the solution is to use a virtual extension.

In extensions_custom.conf:

exten => 400,1,Set(__SIPADDHEADER=Call-Info: \;answer-after=0)
exten => 400,2,Set(__ALERT_INFO=Auto Answer)
exten => 400,3,Set(__SIP_URI_OPTIONS=intercom=true)
exten => 400,4,ChanIsAvail(SIP/200&SIP/400,js)
exten => 400,5,Macro(user-callerid,)
exten => 400,6,Dial(Local/200@from-internal,,A(beep),)
exten => 400,105,Macro(vm,200,BUSY)
exten => 400,106,Wait(5)
exten => 400,107,Macro(hangupcall,)
exten => 400,hint,SIP/200&SIP400

For those who haven't looked-into the various inter-workings of Asterisk, let's go through that step-by-step so that you can customize it if need be:

Lines 1-3: Sets necessary options so that when extension 400 is called, the phone is signaled to activate its intercom (you can customize the intercom behavior in sip.cfg for the Polycoms, but that's outside the scope of this write-up).

Line 4: Checks whether extension 200 is busy--if it IS busy, then skip to priority n+101 (this is logic built into the ChanIsAvail command)--n+101 in this case is line 7.

Line 5: Runs FreePBX's caller-id macro to identify caller.

Line 6: The actual dial command. It dials extension 200 after processing the commands above it, and plays a beep sound to alert the user that someone is about to speak to them. In this case, when you dial 400 from a phone, it 'actually' dials extension 200, with the special conditions listed in lines 1-5. This allows "normal" non-intercom calls to still be placed to extension 200 (by dialing 200 rather than 400).

Line 7: Used if extension 200 is busy--goes to that extension's "on-the-phone" VM box, which essentially prevents a situation where an intercom call goes to call waiting or interrupts. However, in this case, if ext. 200 called 201 while he/she was on the line, 200 would already know that 201 was busy--because of BLF. This line of code is mainly a fail-safe to ensure that if the line is busy, the call is handled propery and prevents a possible interruption, and/or Asterisk locking-up from not knowing what to do.

Lines 8-9: Tells Asterisk to wait 5 seconds after the call is dropped to close out the channel.

Line 10: Maps status of extension 200 to extension 400--this is VERY important to getting BLF to work properly--see below.

2 & 3.) So, the programming aspect for objective #1 is complete. Now, how do we make the Polycoms use this code in the intended manner? Fortunately, thanks to Polycom, this is quite easy. Essentially, activate prescence in sip.cfg, and add each person to the contact directory, but make the contact fields reference the virtual extensions, not the actual extensions the phones are registered to. In this case, enter the following into the directory (speed-dials):

Assistant - 400 (not 200)
Exec - 401 (not 201)

Why reference the virtual extensions? When you do it this way, your Polycom will ask Asterisk for the status of extension 400. Well, extension 400 is obviously not a peer (it's not another phone), but if you have your hints set-up identical to the set-up above, Asterisk will broadcast the status of extension 200 as the status of 400, which is what you want--you want to know whether the phone registered to line 200 is busy.

So, bottom line--when you push the speed-dial labeled "Assistant", Polycom dials extension 400. Asterisk executes the code provided above, and activates the intercom feature on the receiving end. The Polycom then tells Asterisk that line 200 is busy (200's status, remember, is mapped to 400), so any Polycom that has "Assistant" as a speed-dial will show it as busy.

What happens if a regular call comes in from the outside to the assistant? Extension 200 is rung, and when it is picked up, the exec's phone (and anyone else who has Assistant as a speed-dial) will show the assistant as status busy.

You get the best of both worlds.

4.) Finally, the assistant needs to be able to field a call, hit transfer, have the exec's phone beep (to announce the call), then hit transfer again to bridge the two calls together. Likewise, the exec may want the assistant to connect him/her with someone else. The assistant can do this as well. At first, I used the newer Asterisk Page() command, as it was easier to implement, since most of the coding was built-in. This worked great, until I tried to transfer the call. For some reason, a call placed through the Page() command does NOT like to be transferred, and ends up simply being dropped if you try to do it.

That's it--sorry for the length and wordiness--I hope this helps some of you who may have similar needs in your various installed environments. Please let me know if you have any questions about this set-up. I will be happy to answer them to the best of my ability.

ALSO, if you are skilled with Asterisk and would like to critique my code above, I would love that--it would be great to know if it can be made more efficient. Any additions or suggestions for changes are welcome.

Thanks!

--

Preston Edwards



philippel
Posts: 700
Member Since:
2006-05-31
Maybe I'm missing something,

Maybe I'm missing something, but why not just:

exten => *80200,hint,SIP/200

and then make the speedial/blf *80200?

(and note - if intercom is important to you, take a look at the 2.4 beta as it is much improved and provides other important features that you may be interested in).

Also - why don't you go put a feature request into the FreePBX tracker to automatically add the intercom hint, and maybe we can get it into 2.4 before it goes final. Probably not a bad thing to add.

But ... if I missed something above that won't accomplish what you want to do, let me know - maybe I read to quickly.

--

Philippe Lindheimer, FreePBX® Project Leader
http://freepbx.org - #freepbx on irc.freenode.net
http://freepbx.org/forums - The FreePBX® Forum
OTTS Training - Apr 27-29, Huntsville, AL



Helix26404
Posts: 298
Member Since:
2006-06-06
Philippe, Thanks for

Philippe,

Thanks for replying. I actually did do that (BLFing the *80200)--reason I changed it is because the intercom function did not include several "extras" that I wanted to implement (I haven't tried 2.4 though):

- Beep (Polycoms beep very quietly due to config in sip.cfg, but I wanted the nice loud Asterisk beep)
- Doesn't provide for the VM transfer if line is busy (paging app does this, but not intercom app).
- I can hit * plus the speed-dial button and it will forward to that user's VM

I snopped around in functions.inc.php in the paging module folder, but I realized that any changes I made there would be erased when upgrading FreePBX--figured I would enter those as feature requests and then do my own thing in extensions_custom.conf until they were added.

I will add a feature request to have the hint created automatically (as you said), the beep, and the call handling if the line is busy.

Thanks again, and Happy Holidays to you and yours.

--

Preston Edwards



domiflichi
Posts: 164
Member Since:
2007-04-06
Preston, I praise you for

Preston,

I praise you for this post. Thank you thank you thank you for this extensive writeup/how to. You see, I've been wanting all the same things as you have, when intercoming someone. I have only a couple of Snom 320 phones right now, because I'm slowly trying to transfer our company from our old Lucent phone system to Trixbox. Now that I copied in your code into our Trixbox, I think we might have gotten over our first big hurdle before proceeding further (the old system has the ability for a button to have presence/intercom/beeping). Your code works great, just testing off the bat. We will surely be using it more and giving it a more 'rigorous' test as time goes on, but so far so good! I didn't even have to change anything on the Snom's configuration! (So hopefully that little tidbit will help someone.)
I've asked a few different times (different questions) on this forum around here for ways to do what you've created here, and I've searched and searched (here and elsewhere on the web) - to have a button programmed with intercom and line presence and the beeping sound, but no one has been able to help, then I came across this posting. I saw that you were working with Polycoms, but decided to try it anyway, and it works!
Also, I really like how you break down what each line does, because being a newbie, I don't really understand all those config files and how they work, especially what each line does, or syntax or anything, so that was cool. How do you learn about all of that anyway? Any good books/sites?

Anyway, awesome post, thank you. And I hope to see more detailed and helpful posts like this in the future.



pca
Posts: 383
Member Since:
2007-01-17
Preston, Very spiffy little

Preston,

Very spiffy little fix you have done here. I just had one question on...

"I can hit * plus the speed-dial button and it will forward to that user's VM"

From working through this, it looks like you would be checking VM for *400 (the virtual extension) and that wouldn't work. Could you explain further?

Thanks.



jfinstrom
Posts: 2008
Member Since:
2007-03-07
Helix could I encourage you

Helix could I encourage you to add this to the wiki

--



domiflichi
Posts: 164
Member Since:
2007-04-06
I second that

Yes, I second that. I know I wish I would've seen something like this on the wiki a long time ago. I'm sure many more people would benefit from this.



kiddbios
Posts: 5
Member Since:
2009-02-03
Can this be setup so that it

Can this be setup so that it will page by default when you press the speed dial but if you transfer that it will go to the regular extension and not just buzz in on the person?



Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.