http://www.mundoopensource.com.br/en_page_xmpp_asterisk_pratical_example/

www.mundoopensource.com.br/xmpp-asterisk-integration-practical-example-part-2/

In past few years integrate XMPP and Asterisk is one of my principal goals. The development of an realtime communication tool with open source software necessarily needs this two technologies and make it happens is one of my intents.

Nine years ago, since I started to work with Asterisk and Openfire I’m studying a way to do it and when I discovered that Asterisk 11 had improved xmpp support, I noticed that it was the time to make this real.

Using AGIs scripts in python, I started the development of a “tool” that allows users to run commands through their xmpp account in their preferred xmpp client (Pidgin, for example). The current version of my software permits:

Send SIP messages to an extension
    Send text messages (SMS)
    Enable/disable DND for extension
    Enable/disable divert for extension
    Queue logon/logoff
    Show extension informations
    Show queue informations
    Send XMPP message to all extensions logged in a queue
    Show SIP and IAX peers informations
    And other resources under development

For it works you’ll need to create a column in your SIP table to store the extension’s JID. I created a column named JID in my sippeers table.

Now I’ll show you a practical example of this integration.

What do you need?

You’ll need this following items:

A running Asterisk 11 (at least) with res_xmpp support configured.
    A running XMPP server (Openfire 3.9.3 is a good one)
    A JID account for your Asterisk (to use in res_xmpp)

And now ?

First you need to make Asterisk works with your XMPP server. Edit /etc/asterisk/xmpp.conf and create a sessions for you server. Example:

[asterisk]
type=client
serverhost=yourjabberdomain
username=asterisk@yourjabberdomain
secret=password
priority=1
usetls=yes
port=5222
usesasl=yes
status=available
statusmessage="Asterisk Server"
endtodialplan=yes
context=from_xmpp
keepalive=yes

After, edit /etc/asterisk/extensions.conf and create  from_xmpp context with the following content:

[from_xmpp]

exten => s,1,NoOp(XMPP Message)
same => n,NoOp(To: ${MESSAGE(to)})
same => n,NoOp(From: ${MESSAGE(from)})
same => n,NoOp(Message: ${MESSAGE(body)})

same => n,NoOp(Sending SIP message)

; AGI that process message and get the following variables
; ${XMPP_MSG} - message text
; ${XMPP_SIPDEST} - to extension
; ${XMPP_SIPORIG}  - from extension
same => n,agi(process_xmpp_msg.agi)

; Set ${XMPPRESOURCE} = session name in xmpp.conf file (can be a global variable)
same => n,Set(XMPPRESOURCE=asterisk)

same => n,Set(MESSAGE(body)=${XMPP_MSG})
same => n,MessageSend(sip:${XMPP_SIPDEST},sip:${XMPP_SIPORIG})
same => n,JabberSend(${XMPPRESOURCE},${MESSAGE(from):5},"Message sent. Status:${MESSAGE_SEND_STATUS}). )

How to use it?

To  “communicate” with your Asterisk server just send messages to Asterisk JID configured in your xmpp.conf file (in this example, asterisk@yourjabberdomain). The message will be received in xmpp context (from_xmpp context) and stored in  ${MESSAGE} variable. The NoOP commands in the example context are used just to show you  how Asterisk processes the message.

UPDATE: some readers ask me to send my process_xmpp_msg.agi. You can get it here. It was adapted from my original script, so I hope it is working.

XMPP and Asterisk integration的更多相关文章

  1. Xmpp integration with Asterisk

    http://gnu-linux.org/xmpp-integration-with-asterisk.html Xmpp stands for eXtensible Messaging and Pr ...

  2. Github上的原文XMPP环境搭建步骤,英语能力差不多的可以看看

    Getting started using XMPPFramework on iOS Here is a post on StackOverflow describing how to install ...

  3. xmpp muc 群聊协议 4

    7. Occupant Use Cases The main actor in a multi-user chat environment is the occupant, who can be sa ...

  4. [转] Spring Integration 系统集成

    [From] http://blog.csdn.net/w_x_z_/article/details/53316618 pring Ingegration 提供了基于Spring的EIP(Enterp ...

  5. 转 asterisk app命令中文翻译

    常规指令 Authenticate:鉴别用户 VMAuthenticate:根据“voicemail.conf”鉴别用户 Curl:接受外接URLs的修复.支持POSTing DUNDiLookup: ...

  6. xmpp之配置Xcode(1)

    介绍 ios上的XMPPFramework你能够在Xcode/iPhoneXMPP 目录找到,它只是实现了XMPP的一小部分功能. 下面主要介绍在开发XMPPFramework ios应用之前的配置工 ...

  7. 在 Laravel 中使用图片处理库 Integration/Image

    系统需求 PHP >= 5.3 Fileinfo Extension GD Library (>=2.0) … or … Imagick PHP extension (>=6.5.7 ...

  8. 技术笔记:XMPP之openfire+spark+smack

    在即时通信这个领域目前只找到一个XMPP协议,在其协议基础上还是有许多成熟的产品,而且是开源的.所以还是想在这个领域多多了解一下. XMPP协议:具体的概念我就不写了,毕竟这东西网上到处是.简单的说就 ...

  9. 按照Enterprise Integration Pattern搭建服务系统

    在前一篇文章中,我们已经对Enterprise Integration Pattern中所包含的各个组成进行了简单地介绍.限于篇幅(20页Word以内),我并没有深入地讨论各个组成.但是如果要真正地按 ...

随机推荐

  1. hibernate逆向工程生成的实体映射需要修改

    根据实际情况进行修改,主要2处,注释的位置<!-- 把catalog="platform"删掉 -->,<!-- 替换为native -->   <? ...

  2. 修正constructor的指向

    function Aaa(){ } //Aaa.prototype.constructor = Aaa;   //每一个函数都会有的,都是自动生成的 Aaa.prototype.name = '小明' ...

  3. 自己使用Jquery封装各种功能分享

    自己使用Jquery封装各种功能分享: 左右滚动图片 瀑布流 流动显示列表 广告切换 头像切换And广告切换 获取搜索引擎的来源关键字 上面列表中展示的功能都是使用jquery进行封装实现的,希望大家 ...

  4. ext 金额大写

    //数字转换成大写金额函数 function atoc(numberValue) { numberValue = numberValue.replace(/,/g,''); numberValue = ...

  5. Hibernate报错 ** is not mapping

    使用easyui+struts+hibernate 新增加一个页面功能时,总是报错,后来发现是数据库语句,不能写表名称,而是要写映射的数据库实体类名 1.struts文件修改增加action < ...

  6. odoo8 email

    ?? return 地址和 from 地址不一致,为什么不能发送成功? replay地址. 根据对象(比如purchase.order)发送邮件,可以通过supermessage_get_email_ ...

  7. Pyqt5 实时图像滚动

    实时图像 写了一个关于实时图像滚动显示的例子,做个记录. 滚动算法: 难点: 将内存数据绘制到界面,需要用到QImage和QPixmap,使用QImage转换一下,具体参见代码.这个费了好大劲才弄出来 ...

  8. Asp.net MVC中三大描述对象之ActionDescriptor 以及继承类ReflectedControllerDescriptor

    ActionDescriptor抽象类中几个基本的属性: ControllerName:被描述的Controller名称,去除后缀Controller的名称.例如:HomeController则为Ho ...

  9. WebApi(二)-重新封装返回结果

    先创建要返回的结果类型: /// <summary> /// 返回类型 /// </summary> public class ApiResultModel { private ...

  10. DELPHI TMS Advanced Charts 3.8.0.3 Full Source D6-XE6 控件分享

    仅供大家学习使用,请大家支持正版!! TMS Advanced Charts 3.8.0.3 Full Source D6-XE6 该控件用来画图标,压缩包里还有FOR INTRAWEB的版本 链接: ...