Tag Archives: XMPP

VoIP news roundup

Some interesting VoIP-related news I read this week:

TAC to FCC: Set a Date Certain for the End of the PSTN – and the proposed year is 2018. The big concern seems to be maintenance of infrastructure when traditional landline subscribers are dropping off rapidly. I think that infrastructure still has a lot of value to it, but not necessarily for traditional telephone service. What could the utilities or private enterprise do with a copper grid and switching infrastructure that reaches even the most rural parts of the United States?

From the VoIP and Gadgets blog: How Skype Works With Facebook – an interesting interview about how Skype put their technology in the web browser for Facebook video chat. It’s basically the Skype client condensed down to a browser plugin.

Meanwhile, Google is doing it their own way with XMPP: Announcing Google+ Hangouts – Google keeps working at the XMPP extensions to make the protocol media-rich, and now they have group video chat. I don’t have a Google+ account and haven’t tried it out yet.

Google’s offering is standards-based: “To support Hangouts, we built an all-new standards-based cloud video conferencing platform.” And those standards are “XMPP, Jingle, RTP, ICE, STUN, SRTP” and “HTTPS + SRTP”. Some folks would say that it’s not “standards-based” unless SIP is doing the signaling. I think the only thing standard means today is that your work is published for others to use and some technical group of people reviews it. XMPP has that. SIP’s technical body is the IETF and H.323’s technical body is the ITU. Who’s more standard?

The standard with the most implementations wins (Betamax, anyone?) and Google has the weight to tip the end-user-connectivity scales toward XMPP/Jingle. SIP is firmly in place as the current IP trunking standard but might soon be falling behind when it comes to connecting the end-users.

More Asterisk and XMPP (Jabber) integration

Last month I wrote about how to send an XMPP (Jabber) message with Caller*ID information to one or more users when a call comes in to your Asterisk server. This is a simple, one-way notification and is easy to set up. What if we want to interact more fully with the Asterisk server over XMPP?

Please note that I am referring to administrative interaction, not call-level interaction. Asterisk 1.6 adds a JabberReceive command to the dial plan, which would allow some interactive instant messaging within the context of a call.

It turns out that the Asterisk Manager Interface (AMI) posts an event for every XMPP packet–both outgoing and incoming–so writing a Manager application to interface with XMPP is a good way to go.

Writing a daemon in Perl to listen on the Manager interface for XMPP messages, and then interact with Asterisk through the Manager, ends up being pretty straightforward, especially with the Asterisk::AMI module available on CPAN.

Here’s the general flow:

  1. Set up the AMI connection, with Events => ‘on’ so that we get events. The user this script logs in as must be in manager.conf and have permission to receive events and perform any actions you want to be able to perform (originate calls, write to the database, etc.).

  2. Read in a list of buddies from Asterisk’s jabber.conf from whom Asterisk should accept commands.

  3. Set up a simple event loop that filters out just the Jabber events. Mine looks like this:

    while (my $event = $ami->get_event) {
    if ($event->{'Event'} == 'JabberEvent' && defined($event->{'Packet'} )) {
    validateMessage($event->{'Packet'});
    }
    }

  4. Validate the XMPP message. Make sure it came from a valid buddy (step 2) and contains a command.

  5. Process the command, initiating any actions and sending results back to the XMPP buddy. So far in my script I’ve implemented a “call” command, where you can instruct Asterisk to originate a call to a certain number from an extension (or use the ring-all group as the default extension); a “dnc” command, that adds a number to the FreePBX blacklist (telemarketers), and help text.

How does it work? It’s simple–just add the Asterisk XMPP user (the one that sends you the call pop-ups from the previous posting) to your buddy list, and IM it your commands.

What’s left? I’d like to add some more useful interactive features.

  • When a call comes in and I get the Caller*ID pop-up, typing “cell” in the pop-up window will let me redirect the call to my cell phone. Or “vm” for voicemail or “zap” for Zapateller.
  • Missed/placed/received calls lists by pulling records from the CDR database.
  • Channel status, tech (sip/iax2) status, other statuses.

When is enough enough?

You could implement the entire Manager command set in this way, even implementing a very clunky attendant console or ACD supervision tool. That could be a bit much, but I see this being useful as a tool for common call-control tasks and simple administration tasks that would otherwise have to be performed at the command line (requires you to have an SSH session open to the server) or web interface.

If anyone’s interested in the Perl code in its current form, let me know.

XMPP (Jabber) caller ID popups with Asterisk & FreePBX

Asterisk has had a Jabber module for a few years, officially supported since 1.4. The module enables two dialplan functions: JabberStatus, to get presence information, and JabberSend, to send a message. There’s more XMPP/Jabber functionality in Asterisk 1.6, but I’ve been sticking with the long-term support release at this point.

The two Jabber functions would be really useful in a call center where agents have some desktop with XMPP services. The presence function (JabberStatus) can be used in call routing logic, for example, and the JabberSend can be used for screen pops of caller information, perhaps bundled with external data from a CRM package.

Anyway, I wanted to implement caller ID popups on my home system that would IM that info to my wife and me when a call comes in. (She is a willing participant in my nerdy experiments.) Given the above two dialplan functions, the procedure is straightforward:

    1. Execute during the incoming call context
    2. See if buddies are online (and available)
    3. Send an IM to each available buddy with a message that includes the CALLERID variable

Since I am running FreePBX, I wanted to do it the FreePBX way, which means not to mess around with the [from-trunk] (incoming) context directly. Unfortunately there is no direct configuration of the XMPP module from within FreePBX so I have a 15%-FreePBX, 85%-config-files solution.

  1. Make sure the res_jabber.so module is loading. Review /etc/asterisk/modules.conf and verify either autoload=yes with no noload => res_jabber.so, or that without autoload, you are issuing a load => res_jabber.so.

  2. Configure an XMPP account (Gmail, Google Apps, jabber.org, local XMPP server, whatever you like) and set up the details in /etc/asterisk/jabber.conf. The config file is well-documented so I won’t go through it step by step. If you don’t have it, there’s a sample jabber.conf in the Asterisk source tar and a bit of info on the voip-info wiki. Be sure to add the buddies you want to be able to IM with buddy= lines.

  3. Restart Asterisk and use jabber show connected from the CLI to see that your user is now logged in. Review log files and fix until it successfully connects.

  4. Edit /etc/asterisk/extensions_custom.conf and start a new extension under the [from-internal-custom] context. This is going to be a bogus extension number that just issues the Jabber commands and ends. The idea is that it will later be a member of a default incoming calls ring group. I used extension 1099 as it fits in my dialplan and doesn’t interfere with anything else:

    [from-internal-custom]
    ...
    exten => 1099,1,JabberStatus(label,someuser@jabber.org,SOMEUSERSTATUS)
    exten => 1099,n,NoOp(Value of SOMEUSERSTATUS is ${SOMEUSERSTATUS})
    exten => 1099,n,JabberStatus(label,otheruser@jabber.org,OTHERUSERSTATUS)
    exten => 1099,n,NoOp(Value of OTHERUSERSTATUS is ${OTHERUSERSTATUS})
    exten => 1099,n,Execif($[${SOMEUSERSTATUS} < 6],JabberSend,label,someuser@jabber.org,Incoming call from ${CALLERID(all)})
    exten => 1099,n,Execif($[${OTHERUSERSTATUS} < 3],JabberSend,label,otheruser@jabber.org,Incoming call from ${CALLERID(all)})

    Replace label with the [label] set up in jabber.conf for your XMPP connection. Replace someuser@jabber.org with the user ID of a buddy you defined in jabber.conf, and the variable name SOMEUSERSTATUS with whatever you like. The ExecIf statement which checks SOMEUSERSTATUS < 6 sends a message to the buddy if he/she is online. You could use < 3 to IM the buddy only if he/she is in the Available or Chatty state. Do the same for any other users you want to IM on an incoming call.

  5. Reload the dialplan at the CLI with extensions reload and then pick up an extension and dial 1099 or whatever you set up, above. This will trigger the Jabber commands and if you are online, you should get a popup stating that there’s an incoming call from your extension. Experiment and tweak to your liking.

  6. Now to integrate this into FreePBX, we’re going to add 1099 to the list of extensions rung on an incoming call. On my system I ring all extensions when an external call comes in. So to ring all extensions and trigger the Jabber functions as well, I just added 1099# (must include the #) to the bottom of the Extension List on my default ring group.

  7. If you want, you can also add your new custom extension number to the Custom Extensions module in FreePBX, just for tracking purposes.

If you’ve got a more complicated setup with different ring groups per DID or something else, it’s easy to repeat the steps and make additional custom extensions that IM different people or send different messages, then integrate these custom extensions into your FreePBX ring groups. At this point you should be able to apply the config in FreePBX and then wait for an incoming call. As your phones begin to ring, you’ll get an IM if you’re online.