PBX-ing

Thursday, December 23, 2010, at 06:30PM

By Eric Richardson

I spent most of the day today building out blogdowntown's phone system, in preparation for a new employee we're adding in January.

Back in 2007, I wrote about playing with Asterisk and adhearsion for some phone work I was doing at Cartifact. I left the company before we finished that rollout, so I'd never really had a chance to sink my teeth into a more complete system.

Until now, blogdowntown's phone system has been super-simple. It was only for inbound calls, and presented callers with a three-option menu ("For advertising, press 1," etc). From there, it routed those calls to one of two cell phones. I was using both Asterisk and adhearsion for that, but really it was a setup simple enough that I didn't need to be.

The cell phone setup was pretty non-optimal, though. If we didn't answer, the calls would end up in our cell phone voicemails, it used minutes, and there was no way to call out via the office number.

Today's tasks involved adding a few new options to the menu, implementing a user directory and moving the call destinations onto soft-phones.

The menu part is a breeze in adhearsion:

menu 'bdt_menu_prompt2', :timeout => 5.seconds, :tries => 3 do |link|
    link.advertising    1
    link.editorial      2
    link.distribution   3
    link.directory      4

    link.bdtwn_extensions       200..299

    link.on_invalid { play 'invalid' }

    link.on_premature_timeout do |str|
        +general
    end
end

It offers up the options and routes accordingly.

The user directory was similarly simple, though it just calls back into Asterisk:

user_directory {
    execute "Directory", "bdtwn-users", "bdtwn-extensions", "eb(2)"
}

bdtwn_extensions {
    users = {
        '201'   => 'SIP/bdtwn-ewr&SIP/bdtwn-ewr-mobile',
        ...
    }

    if u = users[extension.to_s]
        dial u, :for => 15, :options => "Tr"
        if last_dial_unsuccessful?
            voicemail extension.to_s + "@bdtwn-users"
        end
    else
        play 'invalid'
    end
}

That pair of SIP routes in my user mapping brings me to the last part: the soft-phones. I knew VOIP on the iPhone was coming along these days, but really hadn't taken a look at what was out there until today.

I ended up buying a copy of Groundwire, and am really impressed by the options it offers. Acrobits works around some of the iOS background issues by pushing call notifications to the phone, and then I have the choice whether or not to answer. Caller ID also transmits through correctly, something it didn't do in my previous setup.

I then have a copy of Bria on my laptop, and can ring the call to both (as it's set up to do in the example above) and answer either place. Registering the laptop and mobile as different accounts means I can do fancier things later, routing calls to the mobile only between certain hours, for instance.

Still on the table is implementing a simple Rails interface to manage the system and which phones ring for what menu selections, but I did at least end up with a working system out of the day.