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.
PHP script for sending jabber messages
I wrote the following PHP script to send a message via the jabber IM service to inform about an incoming call. This can be used for e.g. Asterisk 1.2 that doesn't yet come with native Jabber support.
To get it running you need:
To use it in extensions.conf:
exten=>s,1,AGI,jabber.php;Notifyviajabber
exten=>s,n,Wait,30;Waitthirtysecond
exten=>s,n,Answer;Answertheline
Have fun,
-mat-
#!/usr/bin/php -q
<?php
//error_reporting(E_ALL);
ini_set('display_errors', 0 );
ini_set('include_path', '.:/usr/share/pear');
require_once('class.jabber.php');
ob_implicit_flush(true);
set_time_limit(0);
$err=fopen("php://stderr","w");
$in = fopen("php://stdin","r");
while (!feof($in)) {
$temp = str_replace("/n","",fgets($in,4096));
$s = split(":",$temp);
$agi[str_replace("agi_","",$s[0])] = trim($s[1]);
if (($temp == "") || ($temp == "/n")) {
break;
}
}
$JABBER = new Jabber;
$JABBER->server = 'jabber.de.cw.net';
$JABBER->port = 5222;
$JABBER->username = 'asterisk';
$JABBER->password = 'xxxx';
$JABBER->resource = 'ClassJabberPHP';
$JABBER->Connect() or die('Could not connect!');
$JABBER->SendAuth() or die('Could not authenticate!');
$JABBER->SendPresence(NULL,NULL,'online');
// $JABBER->SendMessage('xxx@jabber.de.cw.net', 'chat', NULL, array( 'body' => 'Call from '.$agi['callerid'].' on '.$agi['dnid'] ));
$JABBER->SendMessage('xxx@jabber.de.cw.net', 'chat', NULL, array( 'body' => 'Call from '.htmlspecialchars($agi['callerid']).' on '.$agi['dnid'] ));
$JABBER->Disconnect();
fclose($in);
fclose($err);
?>
app_jabber - jabber client as asterisk application
This 3rd party (out-of-tree) asterisk application is a jabber client for use in the dialplan (extensions.conf). It supports multiple jabber accounts, SSL, message send and receive.
sample extensions.conf:
exten=>8013,1,Set(jid=arbeitszimmer/bef@arbeitszimmer)
exten=>8013,2,Set(JABBER_ACK_MSG=youarebeingcalledby${CALLERIDNUM}.)
exten=>8013,3,JabberReceive(${jid},${JABBER_ACK_MSG})
exten=>8013,4,agi(speak.tcl,${JABBER_MSG})
exten=>8013,5,Set(JABBER_ACK_MSG="${JABBER_MSG}"read.pleasegoahead.)
exten=>8013,6,Goto(3)
exten=>8013,7,Hangup
arbeitszimmer is the name of the configuration section in jabber.conf and also the name of the jabber server (and as such the domain part of the JID).
This configuration is periodically trying to receive a message, which is then acknowledged after it has been read aloud by the festival spech synthesizer.
URL: http://fuhrmannek.de/projects/asterisk/app_jabber.bef
jabber.agi in Python
I've written a Jabber AGI script in Python. It is very simple, using sendxmpp to actually send the Jabber message. You also need pyst for this, which is an AGI interface Python module.
URL: http://www.stuvel.eu/asterisk
OpenFire and Asterisk-IM
The Openfire XMPP server (http://www.igniterealtime.org/) has an asterisk plugin called Asterisk-IM (readme)which uses the manager interface to send 'On the phone' status to XMPP clients. It also has the capability to Pause and Unpause queue members depending on idle status, but that can quickly become. At this moment only the Spark client appears to support this.
Ejabberd modules for Asterisk
mod_asterisk
If you have Asterisk & ejabberd inside your company, make voice calls to a contact you chatting with, by sending special message in chat, e.g. '+'. You don't need to remember contact's phone number, it will be retrieved from contact's vcard, and command Originate sent to AMI.
download http://www.powerpbx.ru/mod_asterisk.erl
mod_client_asterisk
April 2010 we started an Ejabberd module which connect through the Asterisk Manager Interface. This module is looking for call events and updates the status of a known Jabber User. It sort of synchronize jabber users presence based on the phone status. Check it out :
Comments are welcome, please use LaunchPad to submit bugs and ask questions.
See also
分享到:
相关推荐
Asterisk 之数据库配置方案 Asterisk 是一个开源的 PBX(Private Branch Exchange)系统,可以实现电话交换和语音网关的功能。在传统的 Asterisk 配置中,配置文件都是存储在文件系统中的,但是随着系统的复杂度和...
Asterisk是一个开源的IP电话系统,而Asterisk-java则是一个Java库,它提供了与Asterisk服务器交互的能力。这个库使得开发者可以利用Java语言来控制和编程Asterisk PBX(Private Branch eXchange),执行诸如创建、...
Asterisk权威指南中文(第3版) Asterisk权威指南(第3版)第15章自动话务员 Asterisk权威指南(第3版)第02章Asterisk体系结构 Asterisk权威指南(第3版)第05章用户设备配置 Asterisk权威指南(第3版)第06章Dialplan基础 ...
Asterisk.NET 1.6.3 是一个专门为.NET开发者设计的开源库,它提供了对Asterisk PBX系统的编程接口,使得用户可以方便地在C#、VB.NET或其他.NET支持的语言中控制和扩展Asterisk功能。这个库是基于Asterisk Manager ...
Asterisk是一款开源的电话交换机软件,它允许用户创建高度自定义的通信系统,包括VoIP(Voice over IP)电话、会议桥、自动呼叫分配(ACD)以及许多其他电信功能。Asterisk的核心设计理念是灵活性和可扩展性,这使得...
Asterisk是一款开源的IP电话系统,用于构建VoIP(Voice over Internet Protocol)通信平台。在本场景中,我们讨论的是Asterisk的16版本安装包,这将引导我们深入理解Asterisk的核心功能、安装流程以及如何进行编译和...
标签“asterisk record”指的是与Asterisk录音相关的配置和功能,它表明文章将围绕如何在Asterisk中设置和实现录音功能。 在提供的部分内容中,提到了几个关键的配置文件和步骤,这些是实现Asterisk录音功能的核心...
Asterisk AMI(Asterisk Manager Interface)接口是Asterisk PBX系统提供的一种用于远程管理和监控的强大工具。这个接口允许开发者通过编程方式与Asterisk进行交互,执行诸如控制呼叫、获取状态、监听通话等多种操作...
Asterisk是一款开源的IP电话系统,它允许用户创建自己的通信平台,支持VoIP(Voice over IP)服务,包括电话会议、语音邮件和IVR(Interactive Voice Response)等。中文语音包是为Asterisk系统设计的一个关键组件,...
Asterisk是一款开源的PBX(Private Branch Exchange)软件,专用于实现VoIP(Voice over IP)通信。在本文中,我们将深入探讨如何利用Asterisk实现视频通讯功能。实现Asterisk视频通讯的关键在于配置sip.conf文件...
### Asterisk AGI应用详解 #### 一、概述 Asterisk是世界上最流行的开源PBX系统之一,它支持多种通信协议并提供了丰富的功能。在Asterisk中,AGI(Asterisk Gateway Interface)是一种非常重要的接口技术,它允许...
Asterisk是一款强大的开源通信平台,它被广泛用于构建VoIP(Voice over Internet Protocol)电话系统,SIP(Session Initiation Protocol)服务器以及各种通信应用。这个“Asterisk中文文档说明”涵盖了从基础概念到...
Asterisk命令详解 Asterisk是一款开源的电话交换机软件,提供了丰富的命令来管理和控制电话系统。下面是Asterisk的一些常用的命令: 1. amportal 命令 amportal 命令是FreePBX搞的,负责管控Asterisk。amportal ...
Asterisk系统的安装与配置 Asterisk是开源的通讯服务器软件,提供了丰富的通讯功能,包括语音、视频、即时消息等。下面是Asterisk系统的安装与配置指南。 一、安装DAHDI DAHDI是Asterisk管理硬件的插件(中间件)...
Asterisk-Java是一个Java库,它为Asterisk系统提供了AGI(Asterisk Gateway Interface)的实现,方便开发者用Java语言进行Asterisk系统的接口开发。AGI是Asterisk的一个强大特性,允许外部应用程序在呼叫处理过程中...
asterisk拨号方案的配置 Asterisk拨号方案的配置是Voice over Internet Protocol(VoIP)技术中的一个关键组件,它控制着呼入和呼出电话的处理和路由。配置文件“extensions.conf”是Asterisk拨号方案的核心,它...
### Ubuntu16.0.4环境下Asterisk安装经验 #### 概述 本文将详细介绍如何在Ubuntu 16.0.4系统上安装Asterisk。Asterisk是一款非常强大的开源PBX(Private Branch Exchange)系统,它可以将普通的计算机变成一个功能...
Asterisk是一款开源的IP电话系统,用于构建VoIP网络通信基础设施。它的功能强大,能够支持PBX(Private Branch Exchange)、VoIP网关、呼叫中心和许多其他电信应用。在这个"Asterisk客户端.rar"压缩包中,我们主要...
Asterisk是一款开源的PBX(Private Branch Exchange)软件,它允许用户在IP网络上建立电话通信系统。作为Linux环境下的通信平台,Asterisk提供了丰富的功能,包括语音通话、会议、语音邮件、传真等。以下是一些核心...
Asterisk是一款开源的IP电话系统,用于构建VoIP网络通信服务器。在本教程中,我们将深入探讨如何安装和配置Asterisk 1.8版本,这是一个较早但仍然广泛使用的版本,尤其对于初学者来说是个很好的起点。 首先,安装前...