Asterisk Jabber
Page Contents
Jabber is a common name for XMPP-based instant-messaged and communication.
Native jabber support in Asterisk The Jabber module in Asterisk (res_jabber) is available starting from the 1.4 series. Therefore, you can connect Asterisk as a client (or component) to your Jabber server after you've upgraded to 1.4.
Example 1 Here is a macro that takes a look at the user’s presence and routes the call accordingly : if he is online or chatty the call goes to his desk phone and alerts him over IM - otherwise it goes his mobile phone.
[macro-reach_user_with_presence] ; ${ARG1} is a destination such as SIP/jml-senecio ; ${ARG2} is a jabber address such as jim@jabber.grabeuh.com ; ${ARG3} is a destination such as SIP/whatever exten => s,1,jabberstatus(asterisk,${ARG2},STATUS) ;presence in will be 1-6. ;In order : Online, Chatty, Away, XAway, DND, Offline ;If not in roster variable will = 7 exten => s,2,gotoif($[$[${STATUS}]<3]?available:unavailable) ;GotoIf(condition?label_if_true:label_if_false) exten => s,3(available),jabbersend(asterisk,${ARG2},"Call from ${CALLERID(name)} at number ${CALLERID(num)} on ${STRFTIME(,GMT-1,%A %B %d %G at %l:%M:%S %p)}") exten => s,4,Dial(${ARG1}) exten => s,5(unavailable),Dial(${ARG3})
Since we have declared a macro, we have to call it in the context of our choice and assign the relevant values to the macro’s variables:
[whatever_context] ; ${ARG1} is the destination when at desk such as SIP/jim-senecio ; ${ARG2} is a jabber address used at desk such as jim@jabber.grabeuh.com ; ${ARG3} is the destination when not at desk such as SIP/freephonie-out/0666758747 exten => 05600047590,1,Macro(reach_user_with_presence,SIP/jml-senecio,jim@jabber.grabeuh.com,SIP/freephonie-out/0666758747);
That’s all folks ! That is all it takes to have your calls routed to the right phone according to your presence status. It is really that easy.
Example 2 You don't need to run Asterisk as a jabber client, there's also the component way of things: Here's a snippte from the jabber.conf file that allows our Asterisk server to connect to our local XMPP server (jabberd2), as
a component.
[asterisk-component]
type=component
serverhost=jabber.inria.fr
username=asterisk
secret=*******
port=5347
Depending on your XMPP server, the port number may be different. ...
- Native jabber support in Asterisk
- Example 1
- Example 2
- PHP script for sending jabber messages
- app_jabber - jabber client as asterisk application
- jabber.agi in Python
- OpenFire and Asterisk-IM
- ejabberd integration
- See also
Jabber is a common name for XMPP-based instant-messaged and communication.
Native jabber support in Asterisk The Jabber module in Asterisk (res_jabber) is available starting from the 1.4 series. Therefore, you can connect Asterisk as a client (or component) to your Jabber server after you've upgraded to 1.4.
Example 1 Here is a macro that takes a look at the user’s presence and routes the call accordingly : if he is online or chatty the call goes to his desk phone and alerts him over IM - otherwise it goes his mobile phone.
[macro-reach_user_with_presence] ; ${ARG1} is a destination such as SIP/jml-senecio ; ${ARG2} is a jabber address such as jim@jabber.grabeuh.com ; ${ARG3} is a destination such as SIP/whatever exten => s,1,jabberstatus(asterisk,${ARG2},STATUS) ;presence in will be 1-6. ;In order : Online, Chatty, Away, XAway, DND, Offline ;If not in roster variable will = 7 exten => s,2,gotoif($[$[${STATUS}]<3]?available:unavailable) ;GotoIf(condition?label_if_true:label_if_false) exten => s,3(available),jabbersend(asterisk,${ARG2},"Call from ${CALLERID(name)} at number ${CALLERID(num)} on ${STRFTIME(,GMT-1,%A %B %d %G at %l:%M:%S %p)}") exten => s,4,Dial(${ARG1}) exten => s,5(unavailable),Dial(${ARG3})
Since we have declared a macro, we have to call it in the context of our choice and assign the relevant values to the macro’s variables:
[whatever_context] ; ${ARG1} is the destination when at desk such as SIP/jim-senecio ; ${ARG2} is a jabber address used at desk such as jim@jabber.grabeuh.com ; ${ARG3} is the destination when not at desk such as SIP/freephonie-out/0666758747 exten => 05600047590,1,Macro(reach_user_with_presence,SIP/jml-senecio,jim@jabber.grabeuh.com,SIP/freephonie-out/0666758747);
That’s all folks ! That is all it takes to have your calls routed to the right phone according to your presence status. It is really that easy.
Example 2 You don't need to run Asterisk as a jabber client, there's also the component way of things: Here's a snippte from the jabber.conf file that allows our Asterisk server to connect to our local XMPP server (jabberd2), as
a component.
[asterisk-component]
type=component
serverhost=jabber.inria.fr
username=asterisk
secret=*******
port=5347
Depending on your XMPP server, the port number may be different. ...




