Resources.DocsTutAsterisk History

Hide minor edits - Show changes to output

April 24, 2013, at 07:42 PM by 213.233.101.41 -
Changed lines 1-1152 from:
!!Resources -> [[Resources.Documentation | Documentation]] -> [[Resources.DocsTutorials | Tutorials]] -> Realtime OpenSIPS - Asterisk Integration
This page has been visited {$PageCount} times.
(:toc-float Table of Content:)
----

!!! Realtime '''OpenSIPS - Asterisk''' Integration

'''Version 1.0'''

----
!!!! Scope

This tutorial presents the concept and implementation of a realtime integration of OpenSIPS SIP server and Asterisk media server.

OpenSIPS is used a SIP server - users are registering with it, it routes calls, etc - while the purpose of Asterisk is to provide a full set of media services - like voicemail, conference, announcements, etc.

It is a realtime integration because both OpenSIPS and Asterisk are provisioned in the same same time when comes to user accounts - when creating a new OpenSIPS users, automatically Asterisk will learn about it an provide and configure all necessary media services for it.

Both OpenSIPS and Asterisk will be provisioned (for user accounts) via a shared mysql database.

----
!!!! Setup presentation

The following services will be offered by this integrated configuration:
* '''voicemail''' - users will get access to their mailbox; authentication will be done by OpenSIPS; while Asterisk will only provide voicemail IVR (with no access PIN);

* '''conference'''' - opensips will detect and forward calls related to conference service (based on prefixes) to Asterisk, which will provide access (pin based) to the conference rooms;

* '''announcements''' - OpenSIPS will identify the cases and types of announcements that needs to be played and will simply redirect to Asterisk.

----
!!!! Prerequisites

!!!! OpenSIPS

Install OpenSIPS 1.5 with mysql DB support (db_mysql module). if you use sources (tarballs or svn checkouts) do the following:
[@
$ make include_modules="db_mysql" prefix="/" all
$ make include_modules="db_mysql" prefix="/" install
@]

!!!! Asterisk

Use Asterisk 1.4. With 1.6, the DB scheme is a bit different and some additional fields may be required.

You need to have the voicemail support with DB support, so take care and install the '''unixodbc''' support in Asterisk.

Also for the conferencing part ('''meetme''' module) you need the zaptel support ('''ztdummy''' kernel module).

----
!!!! DB Setup

Only '''voicemail''' and '''conference''' services do require DB support. While the '''conference''' DB table will be exclusively be used by Asterisk (OpenSIPS does not require any information form there), the '''voicemail''' service do require a tight sharing of DB information about users between OpenSIPS and Asterisk.

Considering OpenSIPS as the core SIP element of the platform, the core DB will be also belonging to OpenSIPS - we will use the OpenSIPS DB to drive both OpenSIPS and Asterisk. The tables required by Asterisk (for voicemail service) will be mapped over the OpenSIPS tables.

This approach assumes two steps:
# creating the OpenSIP tables and extend them to contain also the fields (info) required by Asterisk.
# creating the mysql views over the OpenSIPS tables, in order to simulate the Asterisk tables

!!!!! Creating the OpenSIPS tables

In file '''/etc/opensips/opensipsctlrc''' enable the mysql backend (see '''DBENGINE''') and also configure the host where the mysql server is located, the name to be used for creating the opensips table, the read-only (ro) and read-write (rw) usernames and passwords to be created for accessing the opensips DB - see all the varaibles with '''DB''' prefix in the file.

Proceed with creation of the OpenSIPS standard database:
[@
$ opensipsdbctl create
@]

If you use the default values to DB host and mysql access users, you can access the DB by:
[@
$ mysql -h'localhost' -u'opensips' -p'opensipsrw' opensips
>
@]

Once the default tables are created, we need to alter the '''subscriber''' table in order to add some additional fields required by the Asterisk DB view. These changes are:
* add '''vm_password''' to be used as voicemail pin
* add '''first_name''' and '''last_name''' as subscriber name
* add '''email_address''' as subscriber's email address
* add '''datetime_created''' as timestamp of the subscriber creation.

Login to the '''opensips''' database (use the above login command) and run:
[@
> alter table subscriber add column `vmail_password` varchar(8) NOT NULL default '1234';
> alter table subscriber add column `first_name` varchar(25) NOT NULL default '';
> alter table subscriber add column `last_name` varchar(45) NOT NULL default '';
> alter table subscriber add column `email_address` varchar(50) NOT NULL default '';
> alter table subscriber add column `datetime_created` datetime NOT NULL default '0000-00-00 00:00:00';
@]

!!!!! Creating the Asterisk tables

Create a separate database to be used by Asterisk - login as root into mysql server and run:
[@
> create database asterisk;
> GRANT ALL PRIVILEGES ON asterisk.* TO 'asterisk' IDENTIFIED BY 'asterisk_pwd';
@]

Create the Asterisk tables which are exclusively used only by Asterisk (as mysql tables):
[@
# create table for the meetme service
CREATE TABLE `meetme` (
`confno` varchar(80) NOT NULL default '0',
`username` varchar(64) NOT NULL default '',
`domain` varchar(128) NOT NULL default '',
`pin` varchar(20) default NULL,
`adminpin` varchar(20) default NULL,
`members` int(11) NOT NULL default '0',
PRIMARY KEY (`confno`)
) ENGINE=MyISAM

# create table to store the voicemail massages
CREATE TABLE `voicemessages` (
`id` int(11) NOT NULL auto_increment,
`msgnum` int(11) NOT NULL default '0',
`dir` varchar(80) default '',
`context` varchar(80) default '',
`macrocontext` varchar(80) default '',
`callerid` varchar(40) default '',
`origtime` varchar(40) default '',
`duration` varchar(20) default '',
`mailboxuser` varchar(80) default '',
`mailboxcontext` varchar(80) default '',
`recording` longblob,
PRIMARY KEY (`id`),
KEY `dir` (`dir`)
) ENGINE=MyISAM
@]

Create the Asterisk tables (as mysql views) that import the information from OpenSIPS tables:
[@
# create the asterisk users tables as a view over the OpenSIPS subscriber table
CREATE VIEW `asterisk`.`sipusers` AS select
`opensips`.`subscriber`.`username` AS `name`,
`opensips`.`subscriber`.`username` AS `username`,
_latin1'friend' AS `type`,
NULL AS `secret`,
`opensips`.`subscriber`.`domain` AS `host`,
concat(`opensips`.`subscriber`.`rpid`,_latin1' ',_latin1'<',`opensips`.`subscriber`.`username`,_latin1'>') AS `callerid`,
_latin1'default' AS `context`,
`opensips`.`subscriber`.`username` AS `mailbox`,
_latin1'yes' AS `nat`,
_latin1'no' AS `qualify`,
`opensips`.`subscriber`.`username` AS `fromuser`,
NULL AS `authuser`,
`opensips`.`subscriber`.`domain` AS `fromdomain`,
NULL AS `insecure`,
_latin1'no' AS `canreinvite`,
NULL AS `disallow`,
NULL AS `allow`,
NULL AS `restrictcid`,
`opensips`.`subscriber`.`domain` AS `defaultip`,
`opensips`.`subscriber`.`domain` AS `ipaddr`,
_latin1'5060' AS `port`,
NULL AS `regseconds`
from `opensips`.`subscriber`;

# create the asterisk voceimail users table as a view over the OpenSIPS subscriber table
CREATE VIEW `asterisk`.`vmusers` AS select
concat(`opensips`.`subscriber`.`username`,`opensips`.`subscriber`.`domain`) AS `uniqueid`,
`opensips`.`subscriber`.`username` AS `customer_id`,
_latin1'default' AS `context`,
`opensips`.`subscriber`.`username` AS `mailbox`,
`opensips`.`subscriber`.`vmail_password` AS `password`,
concat(`opensips`.`subscriber`.`first_name`,_latin1' ',`opensips`.`subscriber`.`last_name`) AS `fullname`,
`opensips`.`subscriber`.`email_address` AS `email`,
NULL AS `pager`,
`opensips`.`subscriber`.`datetime_created` AS `stamp`
from `opensips`.`subscriber`;

#create the asterisk voicemail aliases table as a view over the OpenSIPS dbaliases table
CREATE VIEW `asterisk`.`vmaliases` AS select
`opensips`.`dbaliases`.`alias_username` AS `alias`,
_latin1'default' AS `context`,
`opensips`.`dbaliases`.`username` AS `mailbox`
from `opensips`.`dbaliases`;
@]

Configure the access for Asterisk to the created database (via unixodbc):
* in ''etc/odbcinst.ini''
[@
[MySQL]
Description = MySQL driver
Driver = /usr/lib/odbc/libmyodbc.so
Setup = /usr/lib/odbc/libodbcmyS.so
CPTimeout =
CPReuse =
UsageCount = 1
@]

* in ''/etc/odbc.ini''
[@
[MySQL-asterisk]
Description = MySQL Asterisk database
Trace = Off
TraceFile = stderr
Driver = MySQL
SERVER = localhost
USER = asterisk
PASSWORD = asterisk_pwd
PORT = 3306
DATABASE = asterisk
@]

* in ''/etc/asterisk/res_odbc.conf''
[@
[asterisk]
enabled => yes
dsn => MySQL-asterisk
username => asterisk
password => asterisk_pwd
pre-connect => yes
@]

* in ''/etc/asterisk/extconfig.conf''
[@
sipusers => odbc,asterisk,sipusers
sippeers => odbc,asterisk,sipusers
voicemail => odbc,asterisk,vmusers
meetme => odbc,asterisk,meetme
@]


----
!!!! Asterisk dialplan

The following extensions are set for Asterisk:

# '''VMR_''' prefix indicates that the caller (identify by SIP FROM header) leaves a voicemail message to the user indicated by the RURI (after the prefix).

# '''VM_pickup''' RURI indicates that the caller (identify by SIP FROM header) accesses his own voicemailbox IVR (to listen his messages); the access is done directly, without any PIN required from Asterisk

# '''AN_notavailable''' plays the "Not Available" audio message

# '''AN_time''' plays the current time message (for the given timezone)

# '''AN_date''' plays the current time message (for the given timezone)

# '''AN_echo''' accesses the echo audio service

# '''CR_''' prefix indicates access to a conference room; the number of the room is part of the RURI, after the prefix (like CR_3322); Asterisk will perform the checks for conference room existence and for the access PIN code.



Set in ''/etc/asterisk/extensions.conf''' :
[@
[general]
static=yes
writeprotect=no

[default]

; Voicemail
exten => _VMR_.,n,Ringing
exten => _VMR_.,n,Wait(1)
exten => _VMR_.,n,Answer
exten => _VMR_.,n,Wait(1)
exten => _VMR_.,n,Voicemail(${EXTEN:4}|u)
exten => _VMR_.,n,Hangup

; Allow users to call their Voicemail directly
exten => VM_pickup,n,Ringing
exten => VM_pickup,n,wait(1)
exten => VM_pickup,n,VoicemailMain(${CALLERIDNUM}|s)
exten => VM_pickup,n,Hangup


; announcement: not available
exten => AN_notavailable,1,Ringing
exten => AN_notavailable,2,Playback(notavailable)
exten => AN_notavailable,3,Hangup

; announcement: time
exten => AN_time,1,Ringing
exten => AN_time,2,Wait(1)
exten => AN_time,3,SayUnixTime(,Europe/Bucharest,HMp)
exten => AN_time,4,Hangup

; announcement:date
exten => AN_date,1,Ringing
exten => AN_date,2,SayUnixTime(,Europe/Bucharest,ABdY)
exten => AN_date,3,Hangup

; announcement: echo
exten => AN_echo,1,Ringing
exten => AN_echo,2,Answer
exten => AN_echo,3,Echo

; Conference service
exten => _CR_.,1,Ringing
exten => _CR_.,n,Wait(1)
exten => _CR_.,n,MeetMe(${EXTEN:3}|Mi)


@]


----
!!!! OpenSIPS configuration

In this example we take the OpenSIPS default config file that provides user registration and authentication against the DB and extends the script for adding the following media oriented services:

# voicemail
## leaving a message - if the called user is not registered on OpenSIPS, the call will be forwarded by OpenSIPS (by adding '''VMR_''' prefix) to Asterisk
## listening messages -if a subscriber calls to the *1111 number, OpenSIPS will rewrite it to '''VM_pickup''' and send it to Asterisk
# announcements
## service number *2111 for listening the current time message - OpenSIPS will rewrite it to '''AN_time''' and send it to Asterisk
## service number *2112 for listening the current date message - OpenSIPS will rewrite it to '''AN_date''' and send it to Asterisk
## service number *2113 for accessing the echo service - OpenSIPS will rewrite it to '''AN_echo''' and send it to Asterisk
# conference
## service number *3XXX for dialling into the conference room XXX - OpenSIPS will rewrite it to '''CR_XXX''' and send it to Asterisk

In ''/etc/opensips/opensips.cfg'' place (see the ASTERISK_HOOKS markers to find the script parts relevant to Asterisk integration):
[@

####### Global Parameters #########

debug=3
log_stderror=no
log_facility=LOG_LOCAL0

fork=yes
children=4

/* uncomment the following lines to enable debugging */
#debug=6
#fork=no
#log_stderror=yes

port=5060

/* uncomment and configure the following line if you want opensips to
bind on a specific interface/port/proto (default bind on all available) */
#listen=udp:192.168.1.2:5060


####### Modules Section ########

#set module path
mpath="/lib/opensips/modules/"

loadmodule "db_mysql.so"
loadmodule "signaling.so"
loadmodule "sl.so"
loadmodule "tm.so"
loadmodule "rr.so"
loadmodule "maxfwd.so"
loadmodule "usrloc.so"
loadmodule "registrar.so"
loadmodule "textops.so"
loadmodule "mi_fifo.so"
loadmodule "uri_db.so"
loadmodule "uri.so"
loadmodule "xlog.so"
loadmodule "acc.so"
loadmodule "auth.so"
loadmodule "auth_db.so"
loadmodule "domain.so"

# ----------------- setting module-specific parameters ---------------


# ----- mi_fifo params -----
modparam("mi_fifo", "fifo_name", "/tmp/opensips_fifo")

# ----- rr params -----
# add value to ;lr param to cope with most of the UAs
modparam("rr", "enable_full_lr", 1)
# do not append from tag to the RR (no need for this script)
modparam("rr", "append_fromtag", 0)

# ----- usrloc params -----
modparam("usrloc", "db_mode", 2)
modparam("usrloc", "db_url",
"mysql://opensips:opensipsrw@localhost/opensips")

# ----- uri_db params -----
modparam("uri_db", "use_uri_table", 0)
modparam("uri_db", "db_url", "")

# ----- acc params -----
/* what sepcial events should be accounted ? */
modparam("acc", "early_media", 1)
modparam("acc", "report_ack", 1)
modparam("acc", "report_cancels", 1)
/* account triggers (flags) */
modparam("acc", "failed_transaction_flag", 3)
modparam("acc", "log_flag", 1)
modparam("acc", "log_missed_flag", 2)
/* uncomment the following lines to enable DB accounting also */
modparam("acc", "db_flag", 1)
modparam("acc", "db_missed_flag", 2)

# ----- auth_db params -----
modparam("auth_db", "calculate_ha1", yes)
modparam("auth_db", "password_column", "password")
modparam("auth_db", "db_url",
"mysql://opensips:opensipsrw@localhost/opensips")
modparam("auth_db", "load_credentials", "")

# ----- domain params -----
modparam("domain", "db_url",
"mysql://opensips:opensipsrw@localhost/opensips")
modparam("domain", "db_mode", 1) # Use caching

# ----- multi-module params -----
/* uncomment the following line if you want to enable multi-domain support
in the modules (dafault off) */
modparam("alias_db|auth_db|usrloc|uri_db", "use_domain", 1)


####### Routing Logic ########


# main request routing logic

route{

if (!mf_process_maxfwd_header("10")) {
send_reply("483","Too Many Hops");
exit;
}

if (has_totag()) {
# sequential request withing a dialog should
# take the path determined by record-routing
if (loose_route()) {
if (is_method("BYE")) {
setflag(1); # do accounting ...
setflag(3); # ... even if the transaction fails
} else if (is_method("INVITE")) {
# even if in most of the cases is useless, do RR for
# re-INVITEs alos, as some buggy clients do change route set
# during the dialog.
record_route();
}
# route it out to whatever destination was set by loose_route()
# in $du (destination URI).
route(1);
} else {
if ( is_method("ACK") ) {
if ( t_check_trans() ) {
# non loose-route, but stateful ACK; must be an ACK after
# a 487 or e.g. 404 from upstream server
t_relay();
exit;
} else {
# ACK without matching transaction ->
# ignore and discard
exit;
}
}
send_reply("404","Not here");
}
exit;
}

#initial requests

# CANCEL processing
if (is_method("CANCEL")) {
if (t_check_trans())
t_relay();
exit;
}

t_check_trans();

# authenticate if from local subscriber
if (!(method=="REGISTER") && is_from_local()) {
if (!proxy_authorize("", "subscriber")) {
proxy_challenge("", "0");
exit;
}
if (!check_from()) {
send_reply("403","Forbidden auth ID");
exit;
}

consume_credentials();
# caller authenticated
}

# preloaded route checking
if (loose_route()) {
xlog("L_ERR",
"Attempt to route with preloaded Route's [$fu/$tu/$ru/$ci]");
if (!is_method("ACK"))
send_reply("403","Preload Route denied");
exit;
}

# record routing
if (!is_method("REGISTER|MESSAGE"))
record_route();

# account only INVITEs
if (is_method("INVITE")) {
setflag(1); # do accounting
}

# if not a targetting a local SIP domain, just send it out
# based on DNS (calls to foreign SIP domains)
if (!is_uri_host_local()) {
append_hf("P-hint: outbound\r\n");
route(1);
}

# requests for my domain

if (is_method("REGISTER")) {
# authenticate the REGISTER requests
if (!www_authorize("", "subscriber")) {
www_challenge("", "0");
exit;
}
if (!check_to()) {
send_reply("403","Forbidden auth ID");
exit;
}

if (!save("location"))
sl_reply_error();

exit;
}

if ($rU==NULL) {
# request with no Username in RURI
send_reply("484","Address Incomplete");
exit;
}

# ASTERISK HOOK - BEGIN
# media service number? (digits starting with *)
if ($rU=~"^\*[1-9]+") {
# we do provide access to media services only to our
# subscribers, who were previously authenticated
if (!is_from_local()) {
send_reply("403","Forbidden access to media service");
exit;
}
#identify the services and translate to Asterisk extensions
if ($rU=="*1111") {
# access to own voicemail IVR
seturi("sip:VM_pickup@ASTERISK_IP:ASTERISK_PORT");
} else
if ($rU=="*2111") {
# access to the "say time" announcement
seturi("sip:AN_time@ASTERISK_IP:ASTERISK_PORT");
} else
if ($rU=="*2112") {
# access to the "say date" announcement
seturi("sip:AN_date@ASTERISK_IP:ASTERISK_PORT");
} else
if ($rU=="*2113") {
# access to the "echo" service
seturi("sip:AN_echo@ASTERISK_IP:ASTERISK_PORT");
} else
if ($rU=~"\*3[0-9]{3}") {
# access to the conference service
# remove the "*3" prefix and place the "CR_" prefix
strip(2);
prefix("CR_");
rewritehostport("ASTERISK_IP:ASTERISK_PORT");
} else {
# unknown service
seturi("sip:AN_notavailable@ASTERISK_IP:ASTERISK_PORT");
}
# after setting the proper RURI (to point to corresponding ASTERISK extension),
# simply forward the call
t_relay();
exit;
}
# ASTERISK HOOK - END

# do lookup
if (!lookup("location")) {
# ASTERISK HOOK - BEGIN
# callee is not registered, so different to Voicemail
# First add the VM recording prefix to the RURI
prefix("VMR_");
# forward to the call to Asterisk (replace below with real IP and port)
rewritehostport("ASTERISK_IP:ASTERISK_PORT");
route(1);
# ASTERISK HOOK - END
exit;
}

# when routing via usrloc, log the missed calls also
setflag(2);

# arm a failure route in order to catch failed calls
# targeting local subscribers; if we fail to deliver
# the call to the user, we send the call to voicemail
t_on_failure("1");

route(1);
}


route[1] {
if (!t_relay()) {
sl_reply_error();
};
exit;
}


failure_route[1] {
if (t_was_cancelled()) {
exit;
}

# if the failure code is "408 - timeout" or "486 - busy",
# forward the calls to voicemail recording
if (t_check_status("486|408")) {
# ASTERISK HOOK - BEGIN
# First revert the RURI to get the original user in RURI
# Then add the VM recording prefix to the RURI
revert_uri();
prefix("VMR_");
# forward to the call to Asterisk (replace below with real IP and port)
rewritehostport("ASTERISK_IP:ASTERISK_PORT");
t_relay();
# ASTERISK HOOK - END
exit;
}
}
@]

----
!!!! How to use it

Add a SIP domain in the OpenSIPS server (note that the sip domain most point -via DNS- to your opensips server; also for a SIP domain, you can use the IP address of the SIP server too):
[@
$ mysql -h'localhost' -u'opensips' -p'opensipsrw' opensips
> insert into domain (domain) values ("test.com");

$ opensipsctl fifo domain_reload
@]

Create some subscribers with your OpenSIPS platform (alice@test.com with SIP password '1234'):
[@
$ opensipsctl add alice@test.com 1234
$ opensipsctl add bob@test.com 4321
@]

If you want to change the voicemail pin (for subscriber alice@test.com):
[@
$ mysql -h'localhost' -u'opensips' -p'opensipsrw' opensips
> update subscriber set vm_password="6745" where username="alice" and domain="test.com";
@]

!!!!! Test voicemail
Register your '''alice''' subscriber (ex: using twinkle soft client) to your server. Keep '''bob''' unregistered.

From '''alice''' dial '''bob''' address - you should get the prompt for leaving a voicemail messages/recording.

Register '''bob''' also and dial '''*1111''' - you should get the voicemail IVR and listen the recording left by '''alice'''.


!!!!! Test announcements
Form a registered subscriber, simply dial the service numbers as configured in OpenSIPS (see the beginning of the previous chapter).

!!!!! Test conference

Add a conference room to your system:
[@
$ mysql -h'localhost' -u'asterisk' -p'asterisk_pwd' asterisk
> insert into meetme (confno, pin, adminpin) values ("761","1122","4322");
@]

From a registered SIP user, dial '''*3761''' (to dial in conf room 761) and at IVR prompt type '''1122''' access pin.


----
[[#comment1]](:nl:)>>messagehead<<
!!!!![[~BTN]] &mdash; [-31 August 2009, 22:11-]
>>messageitem<<
Which module is revert_ruri(); located? Seems like my setup throws an error when running because of this. Also when running sl_send_error(). If I comment these 2 lines out opensips runs.

%blue%[bogdan] - he correct name is revert_uri() - I fixed the script; this function is exported directly by core, not by a module. Also, there is no sl_send_error() in the script ?!%%
>><<

[[#comment2]](:nl:)>>messagehead<<
!!!!![[~Eberx]] &mdash; [-01 September 2009, 09:20-]
>>messageitem<<
kuul. Cool.
>><<

[[#comment4]](:nl:)>>messagehead<<
!!!!![[~BTN]] &mdash; [-01 September 2009, 16:14-]
>>messageitem<<
sorry meant sl_reply_error()

Sep 1 10:09:20 [28030] ERROR:core:check_actions: script function "sl_reply_error" (types=1) does not support route type (2)
Sep 1 10:09:20 [28030] ERROR:core:check_actions: route stack[0]=0
Sep 1 10:09:20 [28030] ERROR:core:main: bad function call in config file

%blue%[bogdan] - there was a small mistake in the failure route. I replaced "route(1)" with "t_relay()" - the problem is the "sl_reply_error" function cannot be called from failure route%%
>><<

[[#comment5]](:nl:)>>messagehead<<
!!!!![[~Philippe HENSEL]] &mdash; [-01 September 2009, 22:36-]
>>messageitem<<
Very nice initiative !
Such an update-to-date document is fundamental for a correct use of OpenSIPS in conjunction with Asterisk.
Thanks a lot !!
>><<

[[#comment7]](:nl:)>>messagehead<<
!!!!![[~BTN]] &mdash; [-04 September 2009, 19:37-]
>>messageitem<<
Ok, So one other fix I noticed is that in the Asterisk Dialplan, we changed it to VM_pickup not VMS_pickup and also, these exten =&gt; _VMR_.,n,Ringing
exten =&gt; _VMR_.,n,Wait(1)
exten =&gt; _VMR_.,n,Answer
exten =&gt; _VMR_.,n,Wait(1)
exten =&gt; _VMR_.,n,Voicemail(${EXTEN:4}|u)
exten =&gt; _VMR_.,n,Hangup

; Allow users to call their Voicemail directly
exten =&gt; VMS_pickup,n,Ringing
exten =&gt; VMS_pickup,n,wait(1)
exten =&gt; VMS_pickup,n,VoicemailMain(${CALLERIDNUM}|s)
exten =&gt; VMS_pickup,n,Hangup

should be replaced with

exten =&gt; _VMR_.,1,Ringing
exten =&gt; _VMR_.,n,Wait(1)
exten =&gt; _VMR_.,n,Answer
exten =&gt; _VMR_.,n,Wait(1)
exten =&gt; _VMR_.,n,Voicemail(${EXTEN:4}|u)
exten =&gt; _VMR_.,n,Hangup

; Allow users to call their Voicemail directly
exten =&gt; VM_pickup,1,Ringing
exten =&gt; VM_pickup,n,wait(1)
exten =&gt; VM_pickup,n,VoicemailMain(${CALLERIDNUM}|s)
exten =&gt; VM_pickup,n,Hangup

The type is setting the 1 in the squence, before it was n.

Thanks again.

%blue%[bogdan] - thanks for VMS_pickup -&gt;VM_pickup hint - I updated the tutorial!%%
>><<

[[#comment8]](:nl:)>>messagehead<<
!!!!![[~Karnith]] &mdash; [-15 September 2009, 13:33-]
>>messageitem<<
I get an error with phplib_id when creating the views. There is no table phplib_id in opensips.

How could this be applied to trixbox? I added the phplib_id table and was able to create the view, it shows the data in the db, but it doesn't create extensions for the users.

Thanks for the tut.


%blue%[bogdan] - thanks for reporting the issue - I got rid of that phplib_id and replaced with a concat of username and domain.%%
>><<

[[#comment9]](:nl:)>>messagehead<<
!!!!![[~kowalma]] &mdash; [-15 September 2009, 22:46-]
>>messageitem<<
Hi,

I'm using 1.6 and I think you are missing some fileds:

[Sep 15 22:39:14] WARNING[18413] res_config_odbc.c: Realtime table sipusers@asterisk: column 'regseconds' is not long enough to contain realtime data (needs 11)
[Sep 15 22:39:14] WARNING[18413] res_config_odbc.c: Realtime table sipusers@asterisk requires column 'defaultuser', but that column does not exist!
[Sep 15 22:39:14] WARNING[18413] res_config_odbc.c: Realtime table sipusers@asterisk requires column 'fullcontact', but that column does not exist!
[Sep 15 22:39:14] WARNING[18413] res_config_odbc.c: Realtime table sipusers@asterisk requires column 'regserver', but that column does not exist!
[Sep 15 22:39:14] WARNING[18413] res_config_odbc.c: Realtime table sipusers@asterisk requires column 'useragent', but that column does not exist!
[Sep 15 22:39:14] WARNING[18413] res_config_odbc.c: Realtime table sipusers@asterisk requires column 'lastms', but that column does not exist!

%blue%[bogdan] - it seams that there are some changes in Asterisk DB between 1.4 and 1.6, so I will reduce the compatibility to 1.4, until these errors are fixed in the tutorial. Thanks for your report%%
>><<


[[#comment13]](:nl:)>>messagehead<<
!!!!![[~Duane Larson]] &mdash; [-29 September 2009, 20:01-]
>>messageitem<<
When you update the users PIN by doing the following
$ mysql -h'localhost' -u'opensips' -p'opensipsrw' opensips
&gt; update subscriber set vmail_password="6745" where username="alice" and domain="test.com";

A restart is required for OpenSIPS correct?

%blue%[bogdan] - no restart is required %%
>><<

[[#comment14]](:nl:)>>messagehead<<
!!!!![[~Duane Larson]] &mdash; [-07 October 2009, 00:05-]
>>messageitem<<
Ahhh I just tested reseting the users voicemail password and a restart is not required with OpenSIPS. Sweet! I guess its because of the MySQL views into the OpenSIPS DB. There are two different typos above
Typo
update subscriber set vm_password="6745" where username="alice" and domain="test.com";

It should really be
update subscriber set vmail_password="6745" where username="alice" and domain="test.com";

Typo
concat(`opensips`.`subscriber`.`username`,`opensips`.`subscriber`.`domain`) AS AS `uniqueid`,

It should really be
concat(`opensips`.`subscriber`.`username`,`opensips`.`subscriber`.`domain`) AS `uniqueid`,


Also with this setup you need to make sure that the username is unique because asterisk only looks at the mailbox name and doesn't include the domain name. So you could have an account 24X48XX@test.com and also 24X48XX@foo.com and you would see issues because asterisk will only look for the "24X48XX" in the table and not "24X48XX@test.com"

I was trying to create a system where the primary account name equals the users email address and the dbaliase is the DID, but if I did it like that if the user called in remotely to check their voicemail and Asterisk asks what mailbox they want to check there is no way for the user to type in the email name on the phone. So beware of that.

Thanks for the Tutorial. Worked like a charm.

%blue%[bogdan] - Thanks for the tips: the typos were fixed; for the mailbox issue, maybe having the mailbox name as concat between username and domain (from subscriber table) will solve the problem%%
>><<

[[#comment15]](:nl:)>>messagehead<<
!!!!![[~Karnith]] &mdash; [-25 October 2009, 16:39-]
>>messageitem<<
Because I use trixbox, I did this another way. I copied the dbs over to the opensips server and pointed the trixbox to this server to use the dbs. I wanted to use the full features of trixbox, including the web interfaces for the user accounts, so I will be having opensips subscriber table as a view over the trixbox users table for authentication to the opensips server and user accounts. I happen to be stuck though....

The trixbox users table can provide most of the info needed, but the password field is blank. I need to pull the password from the sip table, but I can't seem to figure out how to make a view properly due to the table structure. I have this so far for the opensips view

CREATE VIEW `opensips`.`subscriber` AS select
`asterisk`.`users`.`extension` AS `id`,
`asterisk`.`users`.`extension` AS `username`,
_latin1'default' AS `domain`,
`asterisk`.`users`.`password` AS `password`
from `asterisk`.`users`;

now the sips table layout is:

|id |keyword |data |flags|

with 22 entries of the id per extension/account. How could I setup in my view the ability to pull from the correct id, keywod and data field to get the password for the account to show in the password virtual table? For example, the password I need is on the 18th row. Could anyone help me with this please?

Once I get this working, I will post what I did in a tutorial.

Thanks,

Karnith
>><<

[[#comment16]](:nl:)>>messagehead<<
!!!!![[~Karnith]] &mdash; [-02 November 2009, 14:08-]
>>messageitem<<
Well, I finally got the view to work using

CREATE VIEW `opensips`.`subscriber` AS select
`asterisk`.`sip`.`id` AS `id`,
`asterisk`.`sip`.`id` AS `username`,
_latin1'emunited' AS `domain`,
`asterisk`.`sip`.`data` AS `password`,
_latin1'' AS `ha1`,
_latin1'' AS `ha2`,
_latin1'' AS `rpid`
from `asterisk`.`sip` where keyword='secret';

I decided to use the sip table as it has just about everything I need to use for accounts in opensips. What I am running into now is when I try to call *97 (for vmail) I get a forbidden access to media service error. Other then that opensips is happy with the view for subscribers and I can make calls to the extensions I create in the freepbx area of trixbox. The view still needs some work, but it is the forbidden error that worries me. In asterisk cli I can see, with sip debug, that if I dial an extension that is not connected it forwards the call to asterisk, but doesn't go to voice mail. Any Ideas on the forbidden error?
>><<

[[#comment17]](:nl:)>>messagehead<<
!!!!![[~alisajjad007]] &mdash; [-03 November 2009, 18:53-]
>>messageitem<<
there is an minor correction that the AS is repeated twice in the script on line 2 i-e in the

# create the asterisk voceimail users table as a view over the OpenSIPS subscriber table


""concat(`opensips`.`subscriber`.`username`,`opensips`.`subscriber`.`domain`) AS AS ""
thanks n regards
Ali

%blue%[bogdan] - fixed, thank you%%

>><<

[[#comment18]](:nl:)>>messagehead<<
!!!!![[~newtoopensips]] &mdash; [-08 December 2009, 11:09-]
>>messageitem<<
I'm using asterisk 1.6 but nothing is working with your script unable to dial voicemail with *1111

what do you mean here:

"Use Asterisk 1.4. With 1.6, the DB scheme is a bit different and some additional fields may be required."

Did you mean "Use Asterisk 1.4. or 1.6"?

%blue%[bogdan] - Asterisk 1.6 is not supported as the DB format changed; you need to use Asterisk 1.4%%
>><<

[[#comment20]](:nl:)>>messagehead<<
!!!!![[~iotohy]] &mdash; [-02 January 2010, 02:51-]
>>messageitem<<
Hi newtoopensips
I use opensips 1.6.0(tls) and Asterisk 1.6.2

you can try

change exten =&gt; _VMR_.,n,Ringing to exten =&gt; _VMR_.,1,Ringing
change exten =&gt; VM_pickup,n,Ringing to exten =&gt; VM_pickup,1,Ringing


>><<

[[#comment21]](:nl:)>>messagehead<<
!!!!![[~balaji.bhr]] &mdash; [-18 January 2010, 16:12-]
>>messageitem<<
On Opensips 1.6 with Asterisk 1.4.28
this is my working config

i found error when iam adding views in the database;

# create the asterisk voceimail users table as a view over the OpenSIPS subscriber table
CREATE VIEW `asterisk`.`vmusers` AS select
concat(`opensips`.`subscriber`.`username`,`opensips`.`subscriber`.`domain`) AS `uniqueid`,
`opensips`.`subscriber`.`username` AS `customer_id`,
_latin1'default' AS `context`,
`opensips`.`subscriber`.`username` AS `mailbox`,
`opensips`.`subscriber`.`vmail_password` AS `password`,
concat(`opensips`.`subscriber`.`first_name`,_latin1' ',`opensips`.`subscriber`.`last_name`) AS `fullname`,
`opensips`.`subscriber`.`email_address` AS `email`,
NULL AS `pager`,
`opensips`.`subscriber`.`datetime_created` AS `stamp`
from `opensips`.`subscriber`;


my extension.conf

[general]
static=yes
writeprotect=no

[default]

; Voicemail
exten =&gt; _VMR_.,1,Voicemail(${EXTEN:4},u)
exten =&gt; _VMR_.,2,Hangup

; Allow users to call their Voicemail directly
exten =&gt; VM_pickup,1,Ringing
exten =&gt; VM_pickup,2,wait(1)
exten =&gt; VM_pickup,3,VoicemailMain(${CALLERID(num)})
exten =&gt; VM_pickup,4,Playback(Goodbye)
exten =&gt; VM_pickup,5,Hangup


; announcement: not available
exten =&gt; AN_notavailable,1,Ringing
exten =&gt; AN_notavailable,2,Playback(notavailable)
exten =&gt; AN_notavailable,3,Hangup

; announcement: time
exten =&gt; AN_time,1,Ringing
exten =&gt; AN_time,2,Wait(1)
exten =&gt; AN_time,3,SayUnixTime(,Europe/Bucharest,HMp)
exten =&gt; AN_time,4,Hangup

; announcement:date
exten =&gt; AN_date,1,Ringing
exten =&gt; AN_date,2,SayUnixTime(,Europe/Bucharest,ABdY)
exten =&gt; AN_date,3,Hangup

; announcement: echo
exten =&gt; AN_echo,1,Ringing
exten =&gt; AN_echo,2,Answer
exten =&gt; AN_echo,3,Echo

; Conference service
exten =&gt; _CR_.,1,Answer
exten =&gt; _CR_.,2,MeetMe(${EXTEN:3},Mi)
exten =&gt; _CR_.,3,Hnagup

>><<

[[#comment16]](:nl:)>>messagehead<<
!!!!![[~please]] &mdash; [-03 March 2010, 19:37-]
>>messageitem<<
HI
I got some problem integration with asterisk

I got error when step #opensipsctl fifo domain reload
This error is "500 command 'domain' not available".

SO I stop the opensipsctl and start again follow

[root@TEST opensips]# opensipsctl start

INFO: Starting OpenSIPS :

ERROR: PID file /var/run/opensips.pid does not exist -- OpenSIPS start failed

So I check in /var/log/messages and got follow

Mar 4 00:25:05 TEST opensips: ERROR:core:yyparse: module 'uri_db.so' not found in '/lib/opensips/modules/'
Mar 4 00:25:05 TEST opensips: CRITICAL:core:yyerror: parse error in config file, line 37, column 13-14: failed to load module
Mar 4 00:25:05 TEST opensips: ERROR:core:sr_load_module: could not open module &lt;/lib/opensips/modules/&gt;: /lib/opensips/modules/: cannot read file data: Is a directory
Mar 4 00:25:05 TEST opensips: CRITICAL:core:yyerror: parse error in config file, line 37, column 13-14: failed to load module
Mar 4 00:25:05 TEST opensips: ERROR:core:set_mod_param_regex: no module matching uri_db found
Mar 4 00:25:05 TEST opensips: CRITICAL:core:yyerror: parse error in config file, line 63, column 19-20: Parameter &lt;use_uri_table&gt; not found in module &lt;uri_db&gt; - can't set
Mar 4 00:25:05 TEST opensips: ERROR:core:set_mod_param_regex: no module matching uri_db found
Mar 4 00:25:05 TEST opensips: CRITICAL:core:yyerror: parse error in config file, line 64, column 20-21: Parameter &lt;db_url&gt; not found in module &lt;uri_db&gt; - can't set
Mar 4 00:25:05 TEST opensips: ERROR:core:main: bad config file (4 errors)


Can You guys instruction to me?
Thanks
Please
>><<

[[#comment17]](:nl:)>>messagehead<<
!!!!![[~help please]] &mdash; [-25 March 2010, 16:13-]
>>messageitem<<
I would like to know if you have to configure some asterisk files, maybe extensions.conf or sips.conf
>><<

[[#comment18]](:nl:)>>messagehead<<
!!!!![[~voipdummy]] &mdash; [-31 March 2010, 11:51-]
>>messageitem<<
Anybody can tell, how MWI (Message Waiting Indication) works in this integration when BOB is online &amp; registered?
>><<

[[#comment19]](:nl:)>>messagehead<<
!!!!![[~lucky_pig]] &mdash; [-12 May 2010, 04:04-]
>>messageitem<<
Help me!
I follow introductions in this page. but I get some problems:
" WARNING[12996]: pbx.c:1344 pbx_exec: The application delimiter is now the comma, not the pipe. Did you forget to convert your dialplan? (VoiceMailMain(|s)) "
" WARNING[3113]: app_voicemail.c:9029 vm_authenticate: Couldn't read username "
" WARNING[3068]: pbx.c:1344 pbx_exec: The application delimiter is now the comma, not the pipe. Did you forget to convert your dialplan? (MeetMe(100|Mi))"

And when asterisk run (asterisk -r), in command CLI&gt; I can't see the script is executed
Please help me! Thanks

>><<

[[#comment20]](:nl:)>>messagehead<<
!!!!![[~lucky_pig]] &mdash; [-26 May 2010, 03:16-]
>>messageitem<<
Now, i'm integrating asterisk and opensips.asterisk is connected database of opensips. i want to execute meetme. in meetme.conf, i don't create any room. confno , pin, members are created in database of opensips.the script is followed:
playing conf-getpin.gsm
after i enter pin. the script is
starting recording of meetme conference 100 into file..............
it is kept that and the script don't run any line. I can't listen to music and announce when only person is registered. But members column is increated in database of opensips.
please, help me!
thank all
>><<

[[#comment21]](:nl:)>>messagehead<<
!!!!![[~son]] &mdash; [-28 May 2010, 11:39-]
>>messageitem<<
In my though, your article presents the way how to integrate Asterisk and OpenSER in which asterisk server and OpenSER server belong to the same subnet.
Now, I assume that asterisk server has IP address 172.28.20.10 and OpenSER server has IP address 10.10.10.10, the problem is how to asterisk and openser can contact to each other ?
What should we implement in extension.conf file, sip.conf file and openser.conf file, etc. In my model, asterisk plays as media gateway and OpenSER plays as SIP proxy.
Can you attach the configuration files to your reply and teach me the way how to integrate Asterisk and OpenSER in this case.
Thank you very much
>><<

[[#comment22]](:nl:)>>messagehead<<
!!!!![[~prem]] &mdash; [-01 June 2010, 09:01-]
>>messageitem<<
Hi, Iam integrating OpenSIPS 1.6.2 and Asterisk1.4.31. I'm using Opensip as Proxy and Asterisk as media server for IVR currenlty. Can any1 tell me; how to integrate for Opensips+Asterisk(IVR) feature. I appreciate your valuable help

>><<


[[#comment23]](:nl:)>>messagehead<<
!!!!![[~KingDavid]] &mdash; [-11 March 2011, 03:06-]
>>messageitem<<
Why are there so many examples of voicemail configuration on opensips+asterisk, and next to nothing on what really matters, which is load balancing and straight send and receive phone calls?... will it be because not many people know how to do it?
>><<


[[#comment24]](:nl:)>>messagehead<<
!!!!![[~Dev]] &mdash; [-13 July 2011, 23:40-]
>>messageitem<<
I would really like to see how to setup opensips on Amazon EC2 and then load balance two Asterisk servers. Do anybody have any idea how to do that. Currently I have Openser as a load balancer for those two Asterisk servers. Now I would like to upgrade that openser server to current opensips version and configure it on Amazon EC2 server. It should load balance my current Asterisk servers. I appreciate any kind of help.
>><<

[[#comment25]](:nl:)>>messagehead<<
!!!!![[~Allen Ford]] &mdash; [-19 December 2011, 08:03-]
>>messageitem<<
Great work here , how do i send calls to voicemail if not answered?
i got alot of info from this site and included alot more work...
Please direct me to the script that sends it to voicemail

%blue%[bogdan] - the script we have here has a failure route which does redirect to VM in case of no answer / busy %%
>><<

[[#comment26]](:nl:)>>messagehead<<
!!!!![[~Sanjay arora]] &mdash; [-27 January 2012, 15:55-]
>>messageitem<<
Hi.. I installed opensips-cp 4.1.. Now as i want to make video conferencing. So what shold be the my next step nad how?? Thanks for help..
>><<

[[#comment27]](:nl:)>>messagehead<<
!!!!![[~abdul basit]] &mdash; [-13 March 2012, 16:40-]
>>messageitem<<
Just for verify if odbc connection is successful.

#isql MySQL-asterisk

+---------------------------------------+
| Connected! |
| |
| sql-statement |
| help [tablename] |
| quit |
| |
+---------------------------------------+
SQL&gt;
>><<

[[#comment28]](:nl:)>>messagehead<<
!!!!![[~Nursultan]] &mdash; [-16 April 2012, 13:53-]
>>messageitem<<
Hi. I'm doing
make prefix=/ all include_modules="db_mysql"
it gives me this:

make[1]: Entering directory `/usr/local/src/opensips_1_7/modules/db_mysql'
Compiling dbase.c
dbase.c:37:25: error: mysql/mysql.h: No such file or directory

Anyone Can help me? I'm using Ubuntu 11.10
>><<

[[#comment29]](:nl:)>>messagehead<<
!!!!![[~Siper]] &mdash; [-29 May 2012, 08:38-]
>>messageitem<<
Hi...
is it possible to update this procedure for opensips 1.8 and asterisk 10?
thanks
>><<

[[#comment30]](:nl:)>>messagehead<<
!!!!![[~Binan]] &mdash; [-18 July 2012, 09:55-]
>>messageitem<<
Update for this article
thanks
>><<


[[#comment31]](:nl:)>>messagehead<<
!!!!![[~nathan]] &mdash; [-12 December 2012, 11:11-]
>>messageitem<<
Can anyone send a new tutorial about latest version asterisk integration with opensips?
>><<

(:commentboxchrono:)
to:
(:redirect Documentation.Tutorials-OpenSIPSAsteriskIntegration quiet=1 :)
December 12, 2012, at 12:11 PM by nathan - Comment added
Added lines 1145-1150:

[[#comment31]](:nl:)>>messagehead<<
!!!!![[~nathan]] &mdash; [-12 December 2012, 11:11-]
>>messageitem<<
Can anyone send a new tutorial about latest version asterisk integration with opensips?
>><<
September 25, 2012, at 11:20 AM by bogdan -
Deleted lines 1144-1149:

[[#comment31]](:nl:)>>messagehead<<
!!!!![[~Janeece]] &mdash; [-24 September 2012, 09:45-]
>>messageitem<<
Boom shakalaka boom boom, probelm solved.
>><<
September 24, 2012, at 10:45 AM by Janeece - Comment added
Added lines 1145-1150:

[[#comment31]](:nl:)>>messagehead<<
!!!!![[~Janeece]] &mdash; [-24 September 2012, 09:45-]
>>messageitem<<
Boom shakalaka boom boom, probelm solved.
>><<
August 21, 2012, at 11:11 AM by bogdan -
Deleted lines 1144-1148:
[[#comment31]](:nl:)>>messagehead<<
!!!!![[~Angela]] &mdash; [-19 August 2012, 07:39-]
>>messageitem<<
Good question. The bsesnius phone systems that we provide to clients include a phone server. By having the bsesnius telephone server right in a company's office, they have control over the entire system and there are no residual fees unless they chose to add on additional phones or needed to place and in depth service call (if they chose not to make the changes themselves). The VoIP providers you are speaking of likely provide a Hosted Solution for clients. One example is . With a hosted solution, the server is housed/managed by an outside party, rather than the bsesnius itself, leading to additional fees. If you'd like to know more about owning a bsesnius phone system vs. utilizing a hosted solution, I encourage you to read our Blog . Obviously, we don't believe this is the best choice for bsesniuses due to the long term costs, but some individuals do choose to go this route.
>><<
August 19, 2012, at 08:39 AM by Angela - Comment added
Added lines 1143-1148:
>><<

[[#comment31]](:nl:)>>messagehead<<
!!!!![[~Angela]] &mdash; [-19 August 2012, 07:39-]
>>messageitem<<
Good question. The bsesnius phone systems that we provide to clients include a phone server. By having the bsesnius telephone server right in a company's office, they have control over the entire system and there are no residual fees unless they chose to add on additional phones or needed to place and in depth service call (if they chose not to make the changes themselves). The VoIP providers you are speaking of likely provide a Hosted Solution for clients. One example is . With a hosted solution, the server is housed/managed by an outside party, rather than the bsesnius itself, leading to additional fees. If you'd like to know more about owning a bsesnius phone system vs. utilizing a hosted solution, I encourage you to read our Blog . Obviously, we don't believe this is the best choice for bsesniuses due to the long term costs, but some individuals do choose to go this route.
July 18, 2012, at 10:55 AM by Binan - Comment added
Added lines 1135-1141:
thanks
>><<

[[#comment30]](:nl:)>>messagehead<<
!!!!![[~Binan]] &mdash; [-18 July 2012, 09:55-]
>>messageitem<<
Update for this article
May 29, 2012, at 09:38 AM by Siper - Comment added
Added lines 1128-1135:
>><<

[[#comment29]](:nl:)>>messagehead<<
!!!!![[~Siper]] &mdash; [-29 May 2012, 08:38-]
>>messageitem<<
Hi...
is it possible to update this procedure for opensips 1.8 and asterisk 10?
thanks
April 16, 2012, at 02:53 PM by Nursultan - Comment added
Added lines 1114-1127:
>><<

[[#comment28]](:nl:)>>messagehead<<
!!!!![[~Nursultan]] &mdash; [-16 April 2012, 13:53-]
>>messageitem<<
Hi. I'm doing
make prefix=/ all include_modules="db_mysql"
it gives me this:

make[1]: Entering directory `/usr/local/src/opensips_1_7/modules/db_mysql'
Compiling dbase.c
dbase.c:37:25: error: mysql/mysql.h: No such file or directory

Anyone Can help me? I'm using Ubuntu 11.10
March 13, 2012, at 05:40 PM by abdul basit - Comment added
Added lines 1096-1113:
>><<

[[#comment27]](:nl:)>>messagehead<<
!!!!![[~abdul basit]] &mdash; [-13 March 2012, 16:40-]
>>messageitem<<
Just for verify if odbc connection is successful.

#isql MySQL-asterisk

+---------------------------------------+
| Connected! |
| |
| sql-statement |
| help [tablename] |
| quit |
| |
+---------------------------------------+
SQL&gt;
January 27, 2012, at 04:55 PM by Sanjay arora - Comment added
Added lines 1090-1095:
>><<

[[#comment26]](:nl:)>>messagehead<<
!!!!![[~Sanjay arora]] &mdash; [-27 January 2012, 15:55-]
>>messageitem<<
Hi.. I installed opensips-cp 4.1.. Now as i want to make video conferencing. So what shold be the my next step nad how?? Thanks for help..
December 19, 2011, at 11:31 AM by bogdan -
Added lines 1088-1089:

%blue%[bogdan] - the script we have here has a failure route which does redirect to VM in case of no answer / busy %%
December 19, 2011, at 09:03 AM by Allen Ford - Comment added
Added lines 1080-1087:
>><<

[[#comment25]](:nl:)>>messagehead<<
!!!!![[~Allen Ford]] &mdash; [-19 December 2011, 08:03-]
>>messageitem<<
Great work here , how do i send calls to voicemail if not answered?
i got alot of info from this site and included alot more work...
Please direct me to the script that sends it to voicemail
August 11, 2011, at 08:51 PM by bogdan -
Deleted lines 1079-1084:
>><<

[[#comment25]](:nl:)>>messagehead<<
!!!!![[~Brenley]] &mdash; [-11 August 2011, 16:32-]
>>messageitem<<
Cheers pal. I do appreciate the wirting.
August 11, 2011, at 05:32 PM by Brenley - Comment added
Added lines 1080-1085:
>><<

[[#comment25]](:nl:)>>messagehead<<
!!!!![[~Brenley]] &mdash; [-11 August 2011, 16:32-]
>>messageitem<<
Cheers pal. I do appreciate the wirting.
July 14, 2011, at 12:40 AM by 208.34.84.116 - Comment added
Added lines 1075-1080:

[[#comment24]](:nl:)>>messagehead<<
!!!!![[~Dev]] &mdash; [-13 July 2011, 23:40-]
>>messageitem<<
I would really like to see how to setup opensips on Amazon EC2 and then load balance two Asterisk servers. Do anybody have any idea how to do that. Currently I have Openser as a load balancer for those two Asterisk servers. Now I would like to upgrade that openser server to current opensips version and configure it on Amazon EC2 server. It should load balance my current Asterisk servers. I appreciate any kind of help.
>><<
July 05, 2011, at 09:05 AM by bogdan -
Deleted lines 1074-1084:
[[#comment24]](:nl:)>>messagehead<<
!!!!![[~196.31.11.185]] &mdash; [-04 July 2011, 23:40-]
>>messageitem<<
opensip
>><<

[[#comment25]](:nl:)>>messagehead<<
!!!!![[~1963111185]] &mdash; [-04 July 2011, 23:42-]
>>messageitem<<
opensip
>><<
July 05, 2011, at 12:42 AM by 1963111185 - Comment added
Added lines 1077-1082:
>>messageitem<<
opensip
>><<

[[#comment25]](:nl:)>>messagehead<<
!!!!![[~1963111185]] &mdash; [-04 July 2011, 23:42-]
July 05, 2011, at 12:40 AM by 1963111185 - Comment added
Added lines 1073-1078:
>><<

[[#comment24]](:nl:)>>messagehead<<
!!!!![[~196.31.11.185]] &mdash; [-04 July 2011, 23:40-]
>>messageitem<<
opensip
June 27, 2011, at 06:06 PM by 109.99.2.142 -
Deleted lines 1072-1077:
>><<

[[#comment24]](:nl:)>>messagehead<<
!!!!![[~Dortha]] &mdash; [-27 June 2011, 12:43-]
>>messageitem<<
YouÂ’re on top of the game. Thanks for sharnig.
June 27, 2011, at 01:43 PM by Dortha - Comment added
Added lines 1073-1078:
>><<

[[#comment24]](:nl:)>>messagehead<<
!!!!![[~Dortha]] &mdash; [-27 June 2011, 12:43-]
>>messageitem<<
YouÂ’re on top of the game. Thanks for sharnig.
March 11, 2011, at 04:06 AM by KingDavid - Comment added
Added lines 1068-1073:

[[#comment23]](:nl:)>>messagehead<<
!!!!![[~KingDavid]] &mdash; [-11 March 2011, 03:06-]
>>messageitem<<
Why are there so many examples of voicemail configuration on opensips+asterisk, and next to nothing on what really matters, which is load balancing and straight send and receive phone calls?... will it be because not many people know how to do it?
>><<
November 10, 2010, at 10:15 AM by bogdan -
Deleted lines 1067-1433:
[[#comment23]](:nl:)>>messagehead<<
!!!!![[~mnuzaihan]] &mdash; [-21 August 2010, 14:34-]
>>messageitem<<
Hi, I've gotten voicemail, echo, date and time working with Asterisk 1.6.2.11 and OpenSIPs 1.6. The only problem is calls tend to timeout when i'm calling another extension. (It waits for somtime and then times-out [from opensips log] and then moves on to recording a voicemail for a vaild registered user)

May i know what are the DB tables that is required in Asterisk to create views onto OpenSIPS? Especially getting Asterisk to find out about registered c clients part.

Since i have almost everything done with Asterisk 1.6 and OpenSIPs except calling connected extensions, i will put out the information after everything works. (I don't use ODBC btw - i use native MySQL support in Asterisk)
>><<

[[#comment24]](:nl:)>>messagehead<<
!!!!![[~mnuzaihan]] &mdash; [-21 August 2010, 16:04-]
>>messageitem<<
i've tested on Asterisk 1.4.35 and when i call a registered extension, i am having the same problem as Asterisk 1.6
>><<

[[#comment25]](:nl:)>>messagehead<<
!!!!![[~mnuzaihan]] &mdash; [-21 August 2010, 17:47-]
>>messageitem<<
OpenSIPs 1.6 configuration file. (some modules are removed or changed due to merged modules)


debug=3
log_stderror=no
log_facility=LOG_LOCAL0

fork=yes
children=4

/* uncomment the following lines to enable debugging */
#debug=6
#fork=no
#log_stderror=yes

port=5060

/* uncomment and configure the following line if you want opensips to
bind on a specific interface/port/proto (default bind on all available) */
#listen=udp:192.168.1.2:5060


####### Modules Section ########

####### Modules Section ########

#set module path (change this to where your modules are located)
mpath="/lib64/opensips/modules/"

loadmodule "db_mysql.so"
loadmodule "signaling.so"
loadmodule "sl.so"
loadmodule "tm.so"
loadmodule "rr.so"
loadmodule "maxfwd.so"
loadmodule "usrloc.so"
loadmodule "registrar.so"
loadmodule "textops.so"
loadmodule "mi_fifo.so"
# loadmodule "uri_db.so" # uri_db is merged to uri module.
loadmodule "uri.so"
# loadmodule "xlog.so" # not needed since merged to core.
loadmodule "acc.so"
loadmodule "auth.so"
loadmodule "auth_db.so"
loadmodule "domain.so"

# ----------------- setting module-specific parameters ---------------


# ----- mi_fifo params -----
modparam("mi_fifo", "fifo_name", "/tmp/opensips_fifo")

# ----- rr params -----
# add value to ;lr param to cope with most of the UAs
modparam("rr", "enable_full_lr", 1)
# do not append from tag to the RR (no need for this script)
modparam("rr", "append_fromtag", 0)

# ----- usrloc params -----
modparam("usrloc", "db_mode", 2)
modparam("usrloc", "db_url",
"mysql://opensips:password@localhost/opensips")

# ----- uri_db params -----
modparam("uri", "use_uri_table", 0)
modparam("uri", "db_url", "")

# ----- acc params -----
/* what sepcial events should be accounted ? */
modparam("acc", "early_media", 1)
modparam("acc", "report_ack", 1)
modparam("acc", "report_cancels", 1)
/* account triggers (flags) */
modparam("acc", "failed_transaction_flag", 3)
modparam("acc", "log_flag", 1)
modparam("acc", "log_missed_flag", 2)
/* uncomment the following lines to enable DB accounting also */
modparam("acc", "db_flag", 1)
modparam("acc", "db_missed_flag", 2)

# ----- auth_db params -----
modparam("auth_db", "calculate_ha1", yes)
modparam("auth_db", "password_column", "password")
modparam("auth_db", "db_url",
"mysql://opensips:password@localhost/opensips")
modparam("auth_db", "load_credentials", "")

# ----- domain params -----

modparam("domain", "db_url",
"mysql://opensipsro:newcastle@localhost/opensips")
modparam("domain", "db_mode", 1) # Use caching

# ----- multi-module params -----
/* uncomment the following line if you want to enable multi-domain support
in the modules (dafault off) */
modparam("alias_db|auth_db|usrloc|uri_db", "use_domain", 1)


####### Routing Logic ########


# main request routing logic

route{

if (!mf_process_maxfwd_header("10")) {
send_reply("483","Too Many Hops");
exit;
}

if (has_totag()) {
# sequential request withing a dialog should
# take the path determined by record-routing
if (loose_route()) {
if (is_method("BYE")) {
setflag(1); # do accounting ...
setflag(3); # ... even if the transaction fails
} else if (is_method("INVITE")) {
# even if in most of the cases is useless, do RR for
# re-INVITEs alos, as some buggy clients do change route set
# during the dialog.
record_route();
}
# route it out to whatever destination was set by loose_route()
# in $du (destination URI).
route(1);
} else {
if ( is_method("ACK") ) {
if ( t_check_trans() ) {

# non loose-route, but stateful ACK; must be an ACK after
# a 487 or e.g. 404 from upstream server
t_relay();
exit;
} else {
# ACK without matching transaction -&gt;
# ignore and discard
exit;
}
}
send_reply("404","Not here");
}
exit;
}

#initial requests

# CANCEL processing
if (is_method("CANCEL")) {
if (t_check_trans())
t_relay();

exit;
}

t_check_trans();

# authenticate if from local subscriber
if (!(method=="REGISTER") &amp;&amp; is_from_local()) {
if (!proxy_authorize("", "subscriber")) {
proxy_challenge("", "0");
exit;
}
## check_from changed to db_check_from in 1.6.
if (!db_check_from()) {
send_reply("403","Forbidden auth ID");
exit;
}

consume_credentials();
# caller authenticated
}

# preloaded route checking
if (loose_route()) {

xlog("L_ERR",
"Attempt to route with preloaded Route's [$fu/$tu/$ru/$ci]");
if (!is_method("ACK"))
send_reply("403","Preload Route denied");
exit;
}

# record routing
if (!is_method("REGISTER|MESSAGE"))
record_route();

# account only INVITEs
if (is_method("INVITE")) {
setflag(1); # do accounting
}

# if not a targetting a local SIP domain, just send it out
# based on DNS (calls to foreign SIP domains)
if (!is_uri_host_local()) {
append_hf("P-hint: outboundrn");
route(1);
}


if (is_method("REGISTER")) {
# authenticate the REGISTER requests
if (!www_authorize("", "subscriber")) {
www_challenge("", "0");
exit;
}
## Changed from check_to to db_check_to in 1.6
if (!db_check_to()) {
send_reply("403","Forbidden auth ID");
exit;
}

if (!save("location"))
sl_reply_error();

exit;
}

if ($rU==NULL) {
# request with no Username in RURI
send_reply("484","Address Incomplete");
exit;

}

# ASTERISK HOOK - BEGIN
# media service number? (digits starting with *)
if ($rU=~"^*[1-9]+") {
# we do provide access to media services only to our
# subscribers, who were previously authenticated
if (!is_from_local()) {
send_reply("403","Forbidden access to media service");
exit;
}
#identify the services and translate to Asterisk extensions
if ($rU=="*1111") {
# access to own voicemail IVR
seturi("sip:VM_pickup@ASTERISK_IP:ASTERISK_PORT");
} else
if ($rU=="*2111") {
# access to the "say time" announcement
seturi("sip:AN_time@ASTERISK_IP:ASTERISK_PORT");
} else
if ($rU=="*2112") {
# access to the "say date" announcement

seturi("sip:AN_date@ASTERISK_IP:ASTERISK_PORT");
} else
if ($rU=="*2113") {
# access to the "echo" service
seturi("sip:AN_echo@ASTERISK_IP:ASTERISK_PORT");
} else
if ($rU=~"*3[0-9]{3}") {
# access to the conference service
# remove the "*3" prefix and place the "CR_" prefix
strip(2);
prefix("CR_");
rewritehostport("ASTERISK_IP:ASTERISK_PORT");
} else {
# unknown service
seturi("sip:AN_notavailable@ASTERISK_IP:ASTERISK_PORT");
}
# after setting the proper RURI (to point to corresponding ASTERISK extension),
# simply forward the call
t_relay();
exit;
}

# ASTERISK HOOK - END

# do lookup
if (!lookup("location")) {
# ASTERISK HOOK - BEGIN
# callee is not registered, so different to Voicemail # First add the VM recording prefix to the RURI
prefix("VMR_");
# forward to the call to Asterisk (replace below with real IP an
d port)
rewritehostport("ASTERISK_IP:ASTERISK_PORT");
route(1);
# ASTERISK HOOK - END
exit;
}

# when routing via usrloc, log the missed calls also
setflag(2);

# arm a failure route in order to catch failed calls
# targeting local subscribers; if we fail to deliver
# the call to the user, we send the call to voicemail

t_on_failure("1");

route(1);
}


route[1] {
if (!t_relay()) {
sl_reply_error();
};
exit;
}


failure_route[1] {
if (t_was_cancelled()) {
exit;
}

# if the failure code is "408 - timeout" or "486 - busy",
# forward the calls to voicemail recording

if (t_check_status("486|408")) {
# ASTERISK HOOK - BEGIN
# First revert the RURI to get the original user in RURI
# Then add the VM recording prefix to the RURI
revert_uri();
prefix("VMR_");
# forward to the call to Asterisk (replace below with real IP and port)
rewritehostport("ASTERISK_IP:ASTERISK_PORT");
t_relay();
# ASTERISK HOOK - END
exit;
}
}
>><<

[[#comment26]](:nl:)>>messagehead<<
!!!!![[~muhammad]] &mdash; [-23 August 2010, 16:54-]
>>messageitem<<
Sorry for the post above, i should have put it somewhere else. Hope someone deletes the configuration file above.

I have however, successfully integrated Asterisk 1.6 and OpenSIPS 1.6.3. DB Layout remains the same, so i did not repeat the information as the above.

Among the changes are:
1. If user does not exist, play AN_notavailable message.
2. If user dials with the starting of “00&amp;#8243; (for standard hardware phones like those hooked up via ATA) or “+” (like mobile phones), it will route out to a VoIP upstream provider to route to standard PSTN. The termination to PSTN via VoIP upstream is handled by Asterisk.
3. Users which are registered (authenticated) to OpenSIPS do not require to enter a password to access voicemail. (Done at asterisk.)
4. Switch to use native MySQL rather than ODBC.
>><<

[[#comment27]](:nl:)>>messagehead<<
!!!!![[~muhammad]] &mdash; [-23 August 2010, 17:18-]
>>messageitem<<
Seems i can't post with a link. But if anyone here needs the URL to the guide, do not hesitate to email me, zaihan(at)unrealasia.net
>><<
August 23, 2010, at 06:18 PM by muhammad - Comment added
Added lines 1428-1433:
>><<

[[#comment27]](:nl:)>>messagehead<<
!!!!![[~muhammad]] &mdash; [-23 August 2010, 17:18-]
>>messageitem<<
Seems i can't post with a link. But if anyone here needs the URL to the guide, do not hesitate to email me, zaihan(at)unrealasia.net
August 23, 2010, at 05:54 PM by muhammad - Comment added
Added lines 1414-1427:
>><<

[[#comment26]](:nl:)>>messagehead<<
!!!!![[~muhammad]] &mdash; [-23 August 2010, 16:54-]
>>messageitem<<
Sorry for the post above, i should have put it somewhere else. Hope someone deletes the configuration file above.

I have however, successfully integrated Asterisk 1.6 and OpenSIPS 1.6.3. DB Layout remains the same, so i did not repeat the information as the above.

Among the changes are:
1. If user does not exist, play AN_notavailable message.
2. If user dials with the starting of “00&amp;#8243; (for standard hardware phones like those hooked up via ATA) or “+” (like mobile phones), it will route out to a VoIP upstream provider to route to standard PSTN. The termination to PSTN via VoIP upstream is handled by Asterisk.
3. Users which are registered (authenticated) to OpenSIPS do not require to enter a password to access voicemail. (Done at asterisk.)
4. Switch to use native MySQL rather than ODBC.
August 21, 2010, at 06:47 PM by mnuzaihan - Comment added
Added lines 1082-1413:
>><<

[[#comment25]](:nl:)>>messagehead<<
!!!!![[~mnuzaihan]] &mdash; [-21 August 2010, 17:47-]
>>messageitem<<
OpenSIPs 1.6 configuration file. (some modules are removed or changed due to merged modules)


debug=3
log_stderror=no
log_facility=LOG_LOCAL0

fork=yes
children=4

/* uncomment the following lines to enable debugging */
#debug=6
#fork=no
#log_stderror=yes

port=5060

/* uncomment and configure the following line if you want opensips to
bind on a specific interface/port/proto (default bind on all available) */
#listen=udp:192.168.1.2:5060


####### Modules Section ########

####### Modules Section ########

#set module path (change this to where your modules are located)
mpath="/lib64/opensips/modules/"

loadmodule "db_mysql.so"
loadmodule "signaling.so"
loadmodule "sl.so"
loadmodule "tm.so"
loadmodule "rr.so"
loadmodule "maxfwd.so"
loadmodule "usrloc.so"
loadmodule "registrar.so"
loadmodule "textops.so"
loadmodule "mi_fifo.so"
# loadmodule "uri_db.so" # uri_db is merged to uri module.
loadmodule "uri.so"
# loadmodule "xlog.so" # not needed since merged to core.
loadmodule "acc.so"
loadmodule "auth.so"
loadmodule "auth_db.so"
loadmodule "domain.so"

# ----------------- setting module-specific parameters ---------------


# ----- mi_fifo params -----
modparam("mi_fifo", "fifo_name", "/tmp/opensips_fifo")

# ----- rr params -----
# add value to ;lr param to cope with most of the UAs
modparam("rr", "enable_full_lr", 1)
# do not append from tag to the RR (no need for this script)
modparam("rr", "append_fromtag", 0)

# ----- usrloc params -----
modparam("usrloc", "db_mode", 2)
modparam("usrloc", "db_url",
"mysql://opensips:password@localhost/opensips")

# ----- uri_db params -----
modparam("uri", "use_uri_table", 0)
modparam("uri", "db_url", "")

# ----- acc params -----
/* what sepcial events should be accounted ? */
modparam("acc", "early_media", 1)
modparam("acc", "report_ack", 1)
modparam("acc", "report_cancels", 1)
/* account triggers (flags) */
modparam("acc", "failed_transaction_flag", 3)
modparam("acc", "log_flag", 1)
modparam("acc", "log_missed_flag", 2)
/* uncomment the following lines to enable DB accounting also */
modparam("acc", "db_flag", 1)
modparam("acc", "db_missed_flag", 2)

# ----- auth_db params -----
modparam("auth_db", "calculate_ha1", yes)
modparam("auth_db", "password_column", "password")
modparam("auth_db", "db_url",
"mysql://opensips:password@localhost/opensips")
modparam("auth_db", "load_credentials", "")

# ----- domain params -----

modparam("domain", "db_url",
"mysql://opensipsro:newcastle@localhost/opensips")
modparam("domain", "db_mode", 1) # Use caching

# ----- multi-module params -----
/* uncomment the following line if you want to enable multi-domain support
in the modules (dafault off) */
modparam("alias_db|auth_db|usrloc|uri_db", "use_domain", 1)


####### Routing Logic ########


# main request routing logic

route{

if (!mf_process_maxfwd_header("10")) {
send_reply("483","Too Many Hops");
exit;
}

if (has_totag()) {
# sequential request withing a dialog should
# take the path determined by record-routing
if (loose_route()) {
if (is_method("BYE")) {
setflag(1); # do accounting ...
setflag(3); # ... even if the transaction fails
} else if (is_method("INVITE")) {
# even if in most of the cases is useless, do RR for
# re-INVITEs alos, as some buggy clients do change route set
# during the dialog.
record_route();
}
# route it out to whatever destination was set by loose_route()
# in $du (destination URI).
route(1);
} else {
if ( is_method("ACK") ) {
if ( t_check_trans() ) {

# non loose-route, but stateful ACK; must be an ACK after
# a 487 or e.g. 404 from upstream server
t_relay();
exit;
} else {
# ACK without matching transaction -&gt;
# ignore and discard
exit;
}
}
send_reply("404","Not here");
}
exit;
}

#initial requests

# CANCEL processing
if (is_method("CANCEL")) {
if (t_check_trans())
t_relay();

exit;
}

t_check_trans();

# authenticate if from local subscriber
if (!(method=="REGISTER") &amp;&amp; is_from_local()) {
if (!proxy_authorize("", "subscriber")) {
proxy_challenge("", "0");
exit;
}
## check_from changed to db_check_from in 1.6.
if (!db_check_from()) {
send_reply("403","Forbidden auth ID");
exit;
}

consume_credentials();
# caller authenticated
}

# preloaded route checking
if (loose_route()) {

xlog("L_ERR",
"Attempt to route with preloaded Route's [$fu/$tu/$ru/$ci]");
if (!is_method("ACK"))
send_reply("403","Preload Route denied");
exit;
}

# record routing
if (!is_method("REGISTER|MESSAGE"))
record_route();

# account only INVITEs
if (is_method("INVITE")) {
setflag(1); # do accounting
}

# if not a targetting a local SIP domain, just send it out
# based on DNS (calls to foreign SIP domains)
if (!is_uri_host_local()) {
append_hf("P-hint: outboundrn");
route(1);
}


if (is_method("REGISTER")) {
# authenticate the REGISTER requests
if (!www_authorize("", "subscriber")) {
www_challenge("", "0");
exit;
}
## Changed from check_to to db_check_to in 1.6
if (!db_check_to()) {
send_reply("403","Forbidden auth ID");
exit;
}

if (!save("location"))
sl_reply_error();

exit;
}

if ($rU==NULL) {
# request with no Username in RURI
send_reply("484","Address Incomplete");
exit;

}

# ASTERISK HOOK - BEGIN
# media service number? (digits starting with *)
if ($rU=~"^*[1-9]+") {
# we do provide access to media services only to our
# subscribers, who were previously authenticated
if (!is_from_local()) {
send_reply("403","Forbidden access to media service");
exit;
}
#identify the services and translate to Asterisk extensions
if ($rU=="*1111") {
# access to own voicemail IVR
seturi("sip:VM_pickup@ASTERISK_IP:ASTERISK_PORT");
} else
if ($rU=="*2111") {
# access to the "say time" announcement
seturi("sip:AN_time@ASTERISK_IP:ASTERISK_PORT");
} else
if ($rU=="*2112") {
# access to the "say date" announcement

seturi("sip:AN_date@ASTERISK_IP:ASTERISK_PORT");
} else
if ($rU=="*2113") {
# access to the "echo" service
seturi("sip:AN_echo@ASTERISK_IP:ASTERISK_PORT");
} else
if ($rU=~"*3[0-9]{3}") {
# access to the conference service
# remove the "*3" prefix and place the "CR_" prefix
strip(2);
prefix("CR_");
rewritehostport("ASTERISK_IP:ASTERISK_PORT");
} else {
# unknown service
seturi("sip:AN_notavailable@ASTERISK_IP:ASTERISK_PORT");
}
# after setting the proper RURI (to point to corresponding ASTERISK extension),
# simply forward the call
t_relay();
exit;
}

# ASTERISK HOOK - END

# do lookup
if (!lookup("location")) {
# ASTERISK HOOK - BEGIN
# callee is not registered, so different to Voicemail # First add the VM recording prefix to the RURI
prefix("VMR_");
# forward to the call to Asterisk (replace below with real IP an
d port)
rewritehostport("ASTERISK_IP:ASTERISK_PORT");
route(1);
# ASTERISK HOOK - END
exit;
}

# when routing via usrloc, log the missed calls also
setflag(2);

# arm a failure route in order to catch failed calls
# targeting local subscribers; if we fail to deliver
# the call to the user, we send the call to voicemail

t_on_failure("1");

route(1);
}


route[1] {
if (!t_relay()) {
sl_reply_error();
};
exit;
}


failure_route[1] {
if (t_was_cancelled()) {
exit;
}

# if the failure code is "408 - timeout" or "486 - busy",
# forward the calls to voicemail recording

if (t_check_status("486|408")) {
# ASTERISK HOOK - BEGIN
# First revert the RURI to get the original user in RURI
# Then add the VM recording prefix to the RURI
revert_uri();
prefix("VMR_");
# forward to the call to Asterisk (replace below with real IP and port)
rewritehostport("ASTERISK_IP:ASTERISK_PORT");
t_relay();
# ASTERISK HOOK - END
exit;
}
}
August 21, 2010, at 05:04 PM by mnuzaihan - Comment added
Added lines 1076-1081:
>><<

[[#comment24]](:nl:)>>messagehead<<
!!!!![[~mnuzaihan]] &mdash; [-21 August 2010, 16:04-]
>>messageitem<<
i've tested on Asterisk 1.4.35 and when i call a registered extension, i am having the same problem as Asterisk 1.6
August 21, 2010, at 03:34 PM by mnuzaihan - Comment added
Added lines 1066-1075:
>><<

[[#comment23]](:nl:)>>messagehead<<
!!!!![[~mnuzaihan]] &mdash; [-21 August 2010, 14:34-]
>>messageitem<<
Hi, I've gotten voicemail, echo, date and time working with Asterisk 1.6.2.11 and OpenSIPs 1.6. The only problem is calls tend to timeout when i'm calling another extension. (It waits for somtime and then times-out [from opensips log] and then moves on to recording a voicemail for a vaild registered user)

May i know what are the DB tables that is required in Asterisk to create views onto OpenSIPS? Especially getting Asterisk to find out about registered c clients part.

Since i have almost everything done with Asterisk 1.6 and OpenSIPs except calling connected extensions, i will put out the information after everything works. (I don't use ODBC btw - i use native MySQL support in Asterisk)
June 01, 2010, at 10:01 AM by prem - Comment added
Added lines 1059-1065:
>><<

[[#comment22]](:nl:)>>messagehead<<
!!!!![[~prem]] &mdash; [-01 June 2010, 09:01-]
>>messageitem<<
Hi, Iam integrating OpenSIPS 1.6.2 and Asterisk1.4.31. I'm using Opensip as Proxy and Asterisk as media server for IVR currenlty. Can any1 tell me; how to integrate for Opensips+Asterisk(IVR) feature. I appreciate your valuable help
May 28, 2010, at 12:39 PM by son - Comment added
Added lines 1049-1058:
>><<

[[#comment21]](:nl:)>>messagehead<<
!!!!![[~son]] &mdash; [-28 May 2010, 11:39-]
>>messageitem<<
In my though, your article presents the way how to integrate Asterisk and OpenSER in which asterisk server and OpenSER server belong to the same subnet.
Now, I assume that asterisk server has IP address 172.28.20.10 and OpenSER server has IP address 10.10.10.10, the problem is how to asterisk and openser can contact to each other ?
What should we implement in extension.conf file, sip.conf file and openser.conf file, etc. In my model, asterisk plays as media gateway and OpenSER plays as SIP proxy.
Can you attach the configuration files to your reply and teach me the way how to integrate Asterisk and OpenSER in this case.
Thank you very much
May 26, 2010, at 04:16 AM by lucky_pig - Comment added
Added lines 1037-1048:
>><<

[[#comment20]](:nl:)>>messagehead<<
!!!!![[~lucky_pig]] &mdash; [-26 May 2010, 03:16-]
>>messageitem<<
Now, i'm integrating asterisk and opensips.asterisk is connected database of opensips. i want to execute meetme. in meetme.conf, i don't create any room. confno , pin, members are created in database of opensips.the script is followed:
playing conf-getpin.gsm
after i enter pin. the script is
starting recording of meetme conference 100 into file..............
it is kept that and the script don't run any line. I can't listen to music and announce when only person is registered. But members column is increated in database of opensips.
please, help me!
thank all
May 12, 2010, at 05:04 AM by lucky_pig - Comment added
Added lines 1023-1036:
>><<

[[#comment19]](:nl:)>>messagehead<<
!!!!![[~lucky_pig]] &mdash; [-12 May 2010, 04:04-]
>>messageitem<<
Help me!
I follow introductions in this page. but I get some problems:
" WARNING[12996]: pbx.c:1344 pbx_exec: The application delimiter is now the comma, not the pipe. Did you forget to convert your dialplan? (VoiceMailMain(|s)) "
" WARNING[3113]: app_voicemail.c:9029 vm_authenticate: Couldn't read username "
" WARNING[3068]: pbx.c:1344 pbx_exec: The application delimiter is now the comma, not the pipe. Did you forget to convert your dialplan? (MeetMe(100|Mi))"

And when asterisk run (asterisk -r), in command CLI&gt; I can't see the script is executed
Please help me! Thanks
March 31, 2010, at 12:51 PM by voipdummy - Comment added
Added lines 1017-1022:
>><<

[[#comment18]](:nl:)>>messagehead<<
!!!!![[~voipdummy]] &mdash; [-31 March 2010, 11:51-]
>>messageitem<<
Anybody can tell, how MWI (Message Waiting Indication) works in this integration when BOB is online &amp; registered?
March 25, 2010, at 05:13 PM by help please - Comment added
Added lines 1011-1016:
>><<

[[#comment17]](:nl:)>>messagehead<<
!!!!![[~help please]] &mdash; [-25 March 2010, 16:13-]
>>messageitem<<
I would like to know if you have to configure some asterisk files, maybe extensions.conf or sips.conf
March 03, 2010, at 08:37 PM by please - Comment added
Added lines 976-1010:
>><<

[[#comment16]](:nl:)>>messagehead<<
!!!!![[~please]] &mdash; [-03 March 2010, 19:37-]
>>messageitem<<
HI
I got some problem integration with asterisk

I got error when step #opensipsctl fifo domain reload
This error is "500 command 'domain' not available".

SO I stop the opensipsctl and start again follow

[root@TEST opensips]# opensipsctl start

INFO: Starting OpenSIPS :

ERROR: PID file /var/run/opensips.pid does not exist -- OpenSIPS start failed

So I check in /var/log/messages and got follow

Mar 4 00:25:05 TEST opensips: ERROR:core:yyparse: module 'uri_db.so' not found in '/lib/opensips/modules/'
Mar 4 00:25:05 TEST opensips: CRITICAL:core:yyerror: parse error in config file, line 37, column 13-14: failed to load module
Mar 4 00:25:05 TEST opensips: ERROR:core:sr_load_module: could not open module &lt;/lib/opensips/modules/&gt;: /lib/opensips/modules/: cannot read file data: Is a directory
Mar 4 00:25:05 TEST opensips: CRITICAL:core:yyerror: parse error in config file, line 37, column 13-14: failed to load module
Mar 4 00:25:05 TEST opensips: ERROR:core:set_mod_param_regex: no module matching uri_db found
Mar 4 00:25:05 TEST opensips: CRITICAL:core:yyerror: parse error in config file, line 63, column 19-20: Parameter &lt;use_uri_table&gt; not found in module &lt;uri_db&gt; - can't set
Mar 4 00:25:05 TEST opensips: ERROR:core:set_mod_param_regex: no module matching uri_db found
Mar 4 00:25:05 TEST opensips: CRITICAL:core:yyerror: parse error in config file, line 64, column 20-21: Parameter &lt;db_url&gt; not found in module &lt;uri_db&gt; - can't set
Mar 4 00:25:05 TEST opensips: ERROR:core:main: bad config file (4 errors)


Can You guys instruction to me?
Thanks
Please
February 18, 2010, at 01:23 PM by bogdan - replys on comments were compacted
Changed line 160 from:
concat(`opensips`.`subscriber`.`username`,`opensips`.`subscriber`.`domain`) AS AS `uniqueid`,
to:
concat(`opensips`.`subscriber`.`username`,`opensips`.`subscriber`.`domain`) AS `uniqueid`,
Changed lines 786-787 from:
&gt; update subscriber set vm_password="6745" where username="alice" and domain="test.com";
to:
&gt; update subscriber set vmail_password="6745" where username="alice" and domain="test.com";
Added line 790:
%blue%[bogdan] - no restart is required %%
Deleted line 809:
Added lines 815-816:

%blue%[bogdan] - Thanks for the tips: the typos were fixed; for the mailbox issue, maybe having the mailbox name as concat between username and domain (from subscriber table) will solve the problem%%
Added lines 876-877:
%blue%[bogdan] - fixed, thank you%%
Changed lines 884-888 from:
>><<

[[#comment19]](:nl:)>>messagehead<<
!!!!![[~newtoopensips]] &mdash; [-16 December 2009, 09:54-]
>>messageitem<<
to:
Added lines 890-891:

%blue%[bogdan] - Asterisk 1.6 is not supported as the DB format changed; you need to use Asterisk 1.4%%
February 18, 2010, at 01:07 PM by bogdan - replys on comments were compacted
Added lines 682-683:

%blue%[bogdan] - he correct name is revert_uri() - I fixed the script; this function is exported directly by core, not by a module. Also, there is no sl_send_error() in the script ?!%%
Changed lines 692-693 from:
[[#comment3]](:nl:)>>messagehead<<
!!!!![[~bogdan]] &mdash; [-01 September 2009, 13:58-]
to:
[[#comment4]](:nl:)>>messagehead<<
!!!!![[~BTN]] &mdash; [-01 September 2009, 16:14-]
Deleted lines 694-700:
Hi BTN - the correct name is revert_uri() - I fixed the script; this function is exported directly by core, not by a module. Also, there is no sl_send_error() in the script ?!
Thanks, bogdan
>><<

[[#comment4]](:nl:)>>messagehead<<
!!!!![[~BTN]] &mdash; [-01 September 2009, 16:14-]
>>messageitem<<
Added line 701:
%blue%[bogdan] - there was a small mistake in the failure route. I replaced "route(1)" with "t_relay()" - the problem is the "sl_reply_error" function cannot be called from failure route%%
Changed lines 712-713 from:
[[#comment6]](:nl:)>>messagehead<<
!!!!![[~bogdan]] &mdash; [-02 September 2009, 10:35-]
to:
[[#comment7]](:nl:)>>messagehead<<
!!!!![[~BTN]] &mdash; [-04 September 2009, 19:37-]
Deleted lines 714-719:
BTN, there was a small mistake in the failure route. I replaced "route(1)" with "t_relay()" - the problem is the "sl_reply_error" function cannot be called from failure route
>><<

[[#comment7]](:nl:)>>messagehead<<
!!!!![[~BTN]] &mdash; [-04 September 2009, 19:37-]
>>messageitem<<
Changed line 747 from:
to:
%blue%[bogdan] - thanks for VMS_pickup -&gt;VM_pickup hint - I updated the tutorial!%%
Added lines 758-760:


%blue%[bogdan] - thanks for reporting the issue - I got rid of that phplib_id and replaced with a concat of username and domain.%%
Added line 777:
%blue%[bogdan] - it seams that there are some changes in Asterisk DB between 1.4 and 1.6, so I will reduce the compatibility to 1.4, until these errors are fixed in the tutorial. Thanks for your report%%
Deleted lines 779-795:
[[#comment10]](:nl:)>>messagehead<<
!!!!![[~bogdan]] &mdash; [-22 September 2009, 17:53-]
>>messageitem<<
BTN, thanks for VMS_pickup -&gt;VM_pickup hint - I updated the tutorial!
>><<

[[#comment11]](:nl:)>>messagehead<<
!!!!![[~bogdan]] &mdash; [-22 September 2009, 17:56-]
>>messageitem<<
Karnith, thanks for reporting the issue - I got rid of that phplib_id and replaced with a concat of username and domain.
>><<

[[#comment12]](:nl:)>>messagehead<<
!!!!![[~bogdan]] &mdash; [-22 September 2009, 17:58-]
>>messageitem<<
kowalma, it seams that there are some changes in Asterisk DB between 1.4 and 1.6, so I will reduce the compatibility to 1.4, until these errors are fixed in the tutorial. Thanks for your report.
>><<
January 18, 2010, at 05:12 PM by balajibhr - Comment added
Added lines 926-995:

>><<

[[#comment21]](:nl:)>>messagehead<<
!!!!![[~balaji.bhr]] &mdash; [-18 January 2010, 16:12-]
>>messageitem<<
On Opensips 1.6 with Asterisk 1.4.28
this is my working config

i found error when iam adding views in the database;

# create the asterisk voceimail users table as a view over the OpenSIPS subscriber table
CREATE VIEW `asterisk`.`vmusers` AS select
concat(`opensips`.`subscriber`.`username`,`opensips`.`subscriber`.`domain`) AS `uniqueid`,
`opensips`.`subscriber`.`username` AS `customer_id`,
_latin1'default' AS `context`,
`opensips`.`subscriber`.`username` AS `mailbox`,
`opensips`.`subscriber`.`vmail_password` AS `password`,
concat(`opensips`.`subscriber`.`first_name`,_latin1' ',`opensips`.`subscriber`.`last_name`) AS `fullname`,
`opensips`.`subscriber`.`email_address` AS `email`,
NULL AS `pager`,
`opensips`.`subscriber`.`datetime_created` AS `stamp`
from `opensips`.`subscriber`;


my extension.conf

[general]
static=yes
writeprotect=no

[default]

; Voicemail
exten =&gt; _VMR_.,1,Voicemail(${EXTEN:4},u)
exten =&gt; _VMR_.,2,Hangup

; Allow users to call their Voicemail directly
exten =&gt; VM_pickup,1,Ringing
exten =&gt; VM_pickup,2,wait(1)
exten =&gt; VM_pickup,3,VoicemailMain(${CALLERID(num)})
exten =&gt; VM_pickup,4,Playback(Goodbye)
exten =&gt; VM_pickup,5,Hangup


; announcement: not available
exten =&gt; AN_notavailable,1,Ringing
exten =&gt; AN_notavailable,2,Playback(notavailable)
exten =&gt; AN_notavailable,3,Hangup

; announcement: time
exten =&gt; AN_time,1,Ringing
exten =&gt; AN_time,2,Wait(1)
exten =&gt; AN_time,3,SayUnixTime(,Europe/Bucharest,HMp)
exten =&gt; AN_time,4,Hangup

; announcement:date
exten =&gt; AN_date,1,Ringing
exten =&gt; AN_date,2,SayUnixTime(,Europe/Bucharest,ABdY)
exten =&gt; AN_date,3,Hangup

; announcement: echo
exten =&gt; AN_echo,1,Ringing
exten =&gt; AN_echo,2,Answer
exten =&gt; AN_echo,3,Echo

; Conference service
exten =&gt; _CR_.,1,Answer
exten =&gt; _CR_.,2,MeetMe(${EXTEN:3},Mi)
exten =&gt; _CR_.,3,Hnagup
January 02, 2010, at 03:51 AM by iotohy - Comment added
Added lines 913-926:
>><<

[[#comment20]](:nl:)>>messagehead<<
!!!!![[~iotohy]] &mdash; [-02 January 2010, 02:51-]
>>messageitem<<
Hi newtoopensips
I use opensips 1.6.0(tls) and Asterisk 1.6.2

you can try

change exten =&gt; _VMR_.,n,Ringing to exten =&gt; _VMR_.,1,Ringing
change exten =&gt; VM_pickup,n,Ringing to exten =&gt; VM_pickup,1,Ringing

December 16, 2009, at 10:54 AM by newtoopensips - Comment added
Added lines 903-912:
>><<

[[#comment19]](:nl:)>>messagehead<<
!!!!![[~newtoopensips]] &mdash; [-16 December 2009, 09:54-]
>>messageitem<<
what do you mean here:

"Use Asterisk 1.4. With 1.6, the DB scheme is a bit different and some additional fields may be required."

Did you mean "Use Asterisk 1.4. or 1.6"?
December 08, 2009, at 12:09 PM by newtoopensips - Comment added
Added lines 897-902:
>><<

[[#comment18]](:nl:)>>messagehead<<
!!!!![[~newtoopensips]] &mdash; [-08 December 2009, 11:09-]
>>messageitem<<
I'm using asterisk 1.6 but nothing is working with your script unable to dial voicemail with *1111
November 03, 2009, at 07:53 PM by alisajjad007 - Comment added
Added lines 883-896:
>><<

[[#comment17]](:nl:)>>messagehead<<
!!!!![[~alisajjad007]] &mdash; [-03 November 2009, 18:53-]
>>messageitem<<
there is an minor correction that the AS is repeated twice in the script on line 2 i-e in the

# create the asterisk voceimail users table as a view over the OpenSIPS subscriber table


""concat(`opensips`.`subscriber`.`username`,`opensips`.`subscriber`.`domain`) AS AS ""
thanks n regards
Ali
November 02, 2009, at 03:08 PM by Karnith - Comment added
Added lines 865-882:
>><<

[[#comment16]](:nl:)>>messagehead<<
!!!!![[~Karnith]] &mdash; [-02 November 2009, 14:08-]
>>messageitem<<
Well, I finally got the view to work using

CREATE VIEW `opensips`.`subscriber` AS select
`asterisk`.`sip`.`id` AS `id`,
`asterisk`.`sip`.`id` AS `username`,
_latin1'emunited' AS `domain`,
`asterisk`.`sip`.`data` AS `password`,
_latin1'' AS `ha1`,
_latin1'' AS `ha2`,
_latin1'' AS `rpid`
from `asterisk`.`sip` where keyword='secret';

I decided to use the sip table as it has just about everything I need to use for accounts in opensips. What I am running into now is when I try to call *97 (for vmail) I get a forbidden access to media service error. Other then that opensips is happy with the view for subscribers and I can make calls to the extensions I create in the freepbx area of trixbox. The view still needs some work, but it is the forbidden error that worries me. In asterisk cli I can see, with sip debug, that if I dial an extension that is not connected it forwards the call to asterisk, but doesn't go to voice mail. Any Ideas on the forbidden error?
October 25, 2009, at 05:39 PM by Karnith - Comment added
Added lines 838-864:
>><<

[[#comment15]](:nl:)>>messagehead<<
!!!!![[~Karnith]] &mdash; [-25 October 2009, 16:39-]
>>messageitem<<
Because I use trixbox, I did this another way. I copied the dbs over to the opensips server and pointed the trixbox to this server to use the dbs. I wanted to use the full features of trixbox, including the web interfaces for the user accounts, so I will be having opensips subscriber table as a view over the trixbox users table for authentication to the opensips server and user accounts. I happen to be stuck though....

The trixbox users table can provide most of the info needed, but the password field is blank. I need to pull the password from the sip table, but I can't seem to figure out how to make a view properly due to the table structure. I have this so far for the opensips view

CREATE VIEW `opensips`.`subscriber` AS select
`asterisk`.`users`.`extension` AS `id`,
`asterisk`.`users`.`extension` AS `username`,
_latin1'default' AS `domain`,
`asterisk`.`users`.`password` AS `password`
from `asterisk`.`users`;

now the sips table layout is:

|id |keyword |data |flags|

with 22 entries of the id per extension/account. How could I setup in my view the ability to pull from the correct id, keywod and data field to get the password for the account to show in the password virtual table? For example, the password I need is on the 18th row. Could anyone help me with this please?

Once I get this working, I will post what I did in a tutorial.

Thanks,

Karnith
October 07, 2009, at 01:05 AM by Duane Larson - Comment added
Added lines 813-837:
>><<

[[#comment14]](:nl:)>>messagehead<<
!!!!![[~Duane Larson]] &mdash; [-07 October 2009, 00:05-]
>>messageitem<<
Ahhh I just tested reseting the users voicemail password and a restart is not required with OpenSIPS. Sweet! I guess its because of the MySQL views into the OpenSIPS DB. There are two different typos above
Typo
update subscriber set vm_password="6745" where username="alice" and domain="test.com";

It should really be
update subscriber set vmail_password="6745" where username="alice" and domain="test.com";

Typo
concat(`opensips`.`subscriber`.`username`,`opensips`.`subscriber`.`domain`) AS AS `uniqueid`,

It should really be
concat(`opensips`.`subscriber`.`username`,`opensips`.`subscriber`.`domain`) AS `uniqueid`,



Also with this setup you need to make sure that the username is unique because asterisk only looks at the mailbox name and doesn't include the domain name. So you could have an account 24X48XX@test.com and also 24X48XX@foo.com and you would see issues because asterisk will only look for the "24X48XX" in the table and not "24X48XX@test.com"

I was trying to create a system where the primary account name equals the users email address and the dbaliase is the DID, but if I did it like that if the user called in remotely to check their voicemail and Asterisk asks what mailbox they want to check there is no way for the user to type in the email name on the phone. So beware of that.

Thanks for the Tutorial. Worked like a charm.
September 29, 2009, at 09:01 PM by Duane Larson - Comment added
Added lines 802-812:
>><<

[[#comment13]](:nl:)>>messagehead<<
!!!!![[~Duane Larson]] &mdash; [-29 September 2009, 20:01-]
>>messageitem<<
When you update the users PIN by doing the following
$ mysql -h'localhost' -u'opensips' -p'opensipsrw' opensips
&gt; update subscriber set vm_password="6745" where username="alice" and domain="test.com";

A restart is required for OpenSIPS correct?
September 22, 2009, at 06:59 PM by bogdan -
Changed line 44 from:
Use Asterisk 1.4 or 1.6.
to:
Use Asterisk 1.4. With 1.6, the DB scheme is a bit different and some additional fields may be required.
September 22, 2009, at 06:58 PM by bogdan - Comment added
Added lines 796-801:
>><<

[[#comment12]](:nl:)>>messagehead<<
!!!!![[~bogdan]] &mdash; [-22 September 2009, 17:58-]
>>messageitem<<
kowalma, it seams that there are some changes in Asterisk DB between 1.4 and 1.6, so I will reduce the compatibility to 1.4, until these errors are fixed in the tutorial. Thanks for your report.
September 22, 2009, at 06:56 PM by bogdan - Comment added
Added lines 790-795:
>><<

[[#comment11]](:nl:)>>messagehead<<
!!!!![[~bogdan]] &mdash; [-22 September 2009, 17:56-]
>>messageitem<<
Karnith, thanks for reporting the issue - I got rid of that phplib_id and replaced with a concat of username and domain.
September 22, 2009, at 06:55 PM by bogdan -
Changed line 160 from:
`opensips`.`subscriber`.`phplib_id` AS `uniqueid`,
to:
concat(`opensips`.`subscriber`.`username`,`opensips`.`subscriber`.`domain`) AS AS `uniqueid`,
September 22, 2009, at 06:53 PM by bogdan - Comment added
Added lines 784-789:
>><<

[[#comment10]](:nl:)>>messagehead<<
!!!!![[~bogdan]] &mdash; [-22 September 2009, 17:53-]
>>messageitem<<
BTN, thanks for VMS_pickup -&gt;VM_pickup hint - I updated the tutorial!
September 22, 2009, at 06:50 PM by bogdan - Fixed VMS_pickup ->VM_pickup
Changed lines 262-265 from:
exten => VMS_pickup,n,Ringing
exten => VMS_pickup,n,wait(1)
exten => VMS_pickup,n,VoicemailMain(${CALLERIDNUM}|s)
exten => VMS_pickup,n,Hangup
to:
exten => VM_pickup,n,Ringing
exten => VM_pickup,n,wait(1)
exten => VM_pickup,n,VoicemailMain(${CALLERIDNUM}|s)
exten => VM_pickup,n,Hangup
September 15, 2009, at 11:46 PM by kowalma - Comment added
Added lines 768-783:
>><<

[[#comment9]](:nl:)>>messagehead<<
!!!!![[~kowalma]] &mdash; [-15 September 2009, 22:46-]
>>messageitem<<
Hi,

I'm using 1.6 and I think you are missing some fileds:

[Sep 15 22:39:14] WARNING[18413] res_config_odbc.c: Realtime table sipusers@asterisk: column 'regseconds' is not long enough to contain realtime data (needs 11)
[Sep 15 22:39:14] WARNING[18413] res_config_odbc.c: Realtime table sipusers@asterisk requires column 'defaultuser', but that column does not exist!
[Sep 15 22:39:14] WARNING[18413] res_config_odbc.c: Realtime table sipusers@asterisk requires column 'fullcontact', but that column does not exist!
[Sep 15 22:39:14] WARNING[18413] res_config_odbc.c: Realtime table sipusers@asterisk requires column 'regserver', but that column does not exist!
[Sep 15 22:39:14] WARNING[18413] res_config_odbc.c: Realtime table sipusers@asterisk requires column 'useragent', but that column does not exist!
[Sep 15 22:39:14] WARNING[18413] res_config_odbc.c: Realtime table sipusers@asterisk requires column 'lastms', but that column does not exist!
September 15, 2009, at 02:33 PM by Karnith - Comment added
Added lines 758-767:
>><<

[[#comment8]](:nl:)>>messagehead<<
!!!!![[~Karnith]] &mdash; [-15 September 2009, 13:33-]
>>messageitem<<
I get an error with phplib_id when creating the views. There is no table phplib_id in opensips.

How could this be applied to trixbox? I added the phplib_id table and was able to create the view, it shows the data in the db, but it doesn't create extensions for the users.

Thanks for the tut.
September 04, 2009, at 08:37 PM by BTN - Comment added
Added lines 720-757:
>><<

[[#comment7]](:nl:)>>messagehead<<
!!!!![[~BTN]] &mdash; [-04 September 2009, 19:37-]
>>messageitem<<
Ok, So one other fix I noticed is that in the Asterisk Dialplan, we changed it to VM_pickup not VMS_pickup and also, these exten =&gt; _VMR_.,n,Ringing
exten =&gt; _VMR_.,n,Wait(1)
exten =&gt; _VMR_.,n,Answer
exten =&gt; _VMR_.,n,Wait(1)
exten =&gt; _VMR_.,n,Voicemail(${EXTEN:4}|u)
exten =&gt; _VMR_.,n,Hangup

; Allow users to call their Voicemail directly
exten =&gt; VMS_pickup,n,Ringing
exten =&gt; VMS_pickup,n,wait(1)
exten =&gt; VMS_pickup,n,VoicemailMain(${CALLERIDNUM}|s)
exten =&gt; VMS_pickup,n,Hangup

should be replaced with

exten =&gt; _VMR_.,1,Ringing
exten =&gt; _VMR_.,n,Wait(1)
exten =&gt; _VMR_.,n,Answer
exten =&gt; _VMR_.,n,Wait(1)
exten =&gt; _VMR_.,n,Voicemail(${EXTEN:4}|u)
exten =&gt; _VMR_.,n,Hangup

; Allow users to call their Voicemail directly
exten =&gt; VM_pickup,1,Ringing
exten =&gt; VM_pickup,n,wait(1)
exten =&gt; VM_pickup,n,VoicemailMain(${CALLERIDNUM}|s)
exten =&gt; VM_pickup,n,Hangup

The type is setting the 1 in the squence, before it was n.

Thanks again.

September 02, 2009, at 11:35 AM by bogdan - Comment added
Added lines 714-719:
>><<

[[#comment6]](:nl:)>>messagehead<<
!!!!![[~bogdan]] &mdash; [-02 September 2009, 10:35-]
>>messageitem<<
BTN, there was a small mistake in the failure route. I replaced "route(1)" with "t_relay()" - the problem is the "sl_reply_error" function cannot be called from failure route
September 02, 2009, at 11:34 AM by bogdan - fixed improper call of sl_reply_error from failure route
Changed line 625 from:
route(1);
to:
t_relay();
September 01, 2009, at 11:36 PM by Philippe HENSEL - Comment added
Added lines 706-713:
>><<

[[#comment5]](:nl:)>>messagehead<<
!!!!![[~Philippe HENSEL]] &mdash; [-01 September 2009, 22:36-]
>>messageitem<<
Very nice initiative !
Such an update-to-date document is fundamental for a correct use of OpenSIPS in conjunction with Asterisk.
Thanks a lot !!
September 01, 2009, at 05:14 PM by BTN - Comment added
Added lines 695-705:
>><<

[[#comment4]](:nl:)>>messagehead<<
!!!!![[~BTN]] &mdash; [-01 September 2009, 16:14-]
>>messageitem<<
sorry meant sl_reply_error()

Sep 1 10:09:20 [28030] ERROR:core:check_actions: script function "sl_reply_error" (types=1) does not support route type (2)
Sep 1 10:09:20 [28030] ERROR:core:check_actions: route stack[0]=0
Sep 1 10:09:20 [28030] ERROR:core:main: bad function call in config file
September 01, 2009, at 02:58 PM by bogdan - Comment added
Added lines 688-694:
>><<

[[#comment3]](:nl:)>>messagehead<<
!!!!![[~bogdan]] &mdash; [-01 September 2009, 13:58-]
>>messageitem<<
Hi BTN - the correct name is revert_uri() - I fixed the script; this function is exported directly by core, not by a module. Also, there is no sl_send_error() in the script ?!
Thanks, bogdan
September 01, 2009, at 02:56 PM by bogdan - Fixed small typos in the OpenSIPS script
Changed line 476 from:
sl_send_reply("403","Forbidden auth ID");
to:
send_reply("403","Forbidden auth ID");
Changed line 621 from:
revert_ruri();
to:
revert_uri();
September 01, 2009, at 10:20 AM by Eberx - Comment added
Added lines 682-687:
>><<

[[#comment2]](:nl:)>>messagehead<<
!!!!![[~Eberx]] &mdash; [-01 September 2009, 09:20-]
>>messageitem<<
kuul. Cool.
August 31, 2009, at 11:11 PM by BTN - Comment added
Added lines 678-683:
[[#comment1]](:nl:)>>messagehead<<
!!!!![[~BTN]] &mdash; [-31 August 2009, 22:11-]
>>messageitem<<
Which module is revert_ruri(); located? Seems like my setup throws an error when running because of this. Also when running sl_send_error(). If I comment these 2 lines out opensips runs.
>><<
August 30, 2009, at 07:49 PM by bogdan -
August 30, 2009, at 07:44 PM by bogdan -
Changed line 663 from:
!!!! Test announcements
to:
!!!!! Test announcements
Changed line 666 from:
!!!! Test conference
to:
!!!!! Test conference
August 30, 2009, at 07:42 PM by bogdan -
Changed lines 38-39 from:
make include_modules="db_mysql" prefix="/" all
make include_modules="db_mysql" prefix="/" install
to:
$ make include_modules="db_mysql" prefix="/" all
$ make include_modules="db_mysql" prefix="/" install
Changed line 67 from:
opensipsdbctl create
to:
$ opensipsdbctl create
Changed lines 72-73 from:
mysql -h'localhost' -u'opensips' -p'opensipsrw' opensips
to:
$ mysql -h'localhost' -u'opensips' -p'opensipsrw' opensips
>
Changed line 635 from:
Add a SIP domain in the OpenSIPS server:
to:
Add a SIP domain in the OpenSIPS server (note that the sip domain most point -via DNS- to your opensips server; also for a SIP domain, you can use the IP address of the SIP server too):
Changed line 643 from:
Create a subscriber with OpenSIPS (alice@test.com with SIP password '1234'):
to:
Create some subscribers with your OpenSIPS platform (alice@test.com with SIP password '1234'):
Added line 646:
$ opensipsctl add bob@test.com 4321
Changed lines 653-678 from:
@]
to:
@]

!!!!! Test voicemail
Register your '''alice''' subscriber (ex: using twinkle soft client) to your server. Keep '''bob''' unregistered.

From '''alice''' dial '''bob''' address - you should get the prompt for leaving a voicemail messages/recording.

Register '''bob''' also and dial '''*1111''' - you should get the voicemail IVR and listen the recording left by '''alice'''.


!!!! Test announcements
Form a registered subscriber, simply dial the service numbers as configured in OpenSIPS (see the beginning of the previous chapter).

!!!! Test conference

Add a conference room to your system:
[@
$ mysql -h'localhost' -u'asterisk' -p'asterisk_pwd' asterisk
> insert into meetme (confno, pin, adminpin) values ("761","1122","4322");
@]

From a registered SIP user, dial '''*3761''' (to dial in conf room 761) and at IVR prompt type '''1122''' access pin.


----
(:commentboxchrono:)
August 30, 2009, at 07:30 PM by bogdan -
Added lines 630-651:

----
!!!! How to use it

Add a SIP domain in the OpenSIPS server:
[@
$ mysql -h'localhost' -u'opensips' -p'opensipsrw' opensips
> insert into domain (domain) values ("test.com");

$ opensipsctl fifo domain_reload
@]

Create a subscriber with OpenSIPS (alice@test.com with SIP password '1234'):
[@
$ opensipsctl add alice@test.com 1234
@]

If you want to change the voicemail pin (for subscriber alice@test.com):
[@
$ mysql -h'localhost' -u'opensips' -p'opensipsrw' opensips
> update subscriber set vm_password="6745" where username="alice" and domain="test.com";
@]
August 30, 2009, at 07:18 PM by bogdan -
Added lines 536-541:
# we do provide access to media services only to our
# subscribers, who were previously authenticated
if (!is_from_local()) {
send_reply("403","Forbidden access to media service");
exit;
}
August 30, 2009, at 07:09 PM by bogdan -
Changed line 529 from:
sl_send_reply("484","Address Incomplete");
to:
send_reply("484","Address Incomplete");
Added lines 532-568:

# ASTERISK HOOK - BEGIN
# media service number? (digits starting with *)
if ($rU=~"^\*[1-9]+") {
#identify the services and translate to Asterisk extensions
if ($rU=="*1111") {
# access to own voicemail IVR
seturi("sip:VM_pickup@ASTERISK_IP:ASTERISK_PORT");
} else
if ($rU=="*2111") {
# access to the "say time" announcement
seturi("sip:AN_time@ASTERISK_IP:ASTERISK_PORT");
} else
if ($rU=="*2112") {
# access to the "say date" announcement
seturi("sip:AN_date@ASTERISK_IP:ASTERISK_PORT");
} else
if ($rU=="*2113") {
# access to the "echo" service
seturi("sip:AN_echo@ASTERISK_IP:ASTERISK_PORT");
} else
if ($rU=~"\*3[0-9]{3}") {
# access to the conference service
# remove the "*3" prefix and place the "CR_" prefix
strip(2);
prefix("CR_");
rewritehostport("ASTERISK_IP:ASTERISK_PORT");
} else {
# unknown service
seturi("sip:AN_notavailable@ASTERISK_IP:ASTERISK_PORT");
}
# after setting the proper RURI (to point to corresponding ASTERISK extension),
# simply forward the call
t_relay();
exit;
}
# ASTERISK HOOK - END
August 30, 2009, at 06:58 PM by bogdan -
Changed line 304 from:
## listening messages -if a subscriber calls to the *1111 number, OpenSIPS will rewrite it to '''VM_pickup'' and send it to Asterisk
to:
## listening messages -if a subscriber calls to the *1111 number, OpenSIPS will rewrite it to '''VM_pickup''' and send it to Asterisk
Changed line 312 from:
In ''/etc/opensips/opensips.cfg'' place:
to:
In ''/etc/opensips/opensips.cfg'' place (see the ASTERISK_HOOKS markers to find the script parts relevant to Asterisk integration):
August 30, 2009, at 06:56 PM by bogdan -
Changed lines 535-536 from:
send_reply("404", "Not Found");
exit;
to:
# ASTERISK HOOK - BEGIN
# callee is not registered, so different to Voicemail
# First add the VM recording prefix to the RURI
prefix("VMR_");
# forward to the call to Asterisk (replace below with real IP and port)
rewritehostport("ASTERISK_IP:ASTERISK_PORT");
route(1);
# ASTERISK HOOK - END
exit;
Added lines 549-553:
# arm a failure route in order to catch failed calls
# targeting local subscribers; if we fail to deliver
# the call to the user, we send the call to voicemail
t_on_failure("1");
Changed lines 571-577 from:
# uncomment the following lines if you want to redirect the failed
# calls to a different new destination
##if (t_check_status("486|408")) {
## sethostport("192.168.2.100:5060");
## # do not set the missed call flag again
## t_relay();
##}
to:
# if the failure code is "408 - timeout" or "486 - busy",
# forward the calls to voicemail recording
if (t_check_status("486|408")) {
# ASTERISK HOOK - BEGIN
# First revert the RURI to get the original user in RURI
# Then add the VM recording prefix to the RURI
revert_ruri();
prefix("VMR_");
# forward to the call to Asterisk (replace below with real IP and port)
rewritehostport("ASTERISK_IP:ASTERISK_PORT");
route(1);
# ASTERISK HOOK - END
exit;
}
August 30, 2009, at 06:47 PM by bogdan -
Added lines 311-567:

In ''/etc/opensips/opensips.cfg'' place:
[@

####### Global Parameters #########

debug=3
log_stderror=no
log_facility=LOG_LOCAL0

fork=yes
children=4

/* uncomment the following lines to enable debugging */
#debug=6
#fork=no
#log_stderror=yes

port=5060

/* uncomment and configure the following line if you want opensips to
bind on a specific interface/port/proto (default bind on all available) */
#listen=udp:192.168.1.2:5060


####### Modules Section ########

#set module path
mpath="/lib/opensips/modules/"

loadmodule "db_mysql.so"
loadmodule "signaling.so"
loadmodule "sl.so"
loadmodule "tm.so"
loadmodule "rr.so"
loadmodule "maxfwd.so"
loadmodule "usrloc.so"
loadmodule "registrar.so"
loadmodule "textops.so"
loadmodule "mi_fifo.so"
loadmodule "uri_db.so"
loadmodule "uri.so"
loadmodule "xlog.so"
loadmodule "acc.so"
loadmodule "auth.so"
loadmodule "auth_db.so"
loadmodule "domain.so"

# ----------------- setting module-specific parameters ---------------


# ----- mi_fifo params -----
modparam("mi_fifo", "fifo_name", "/tmp/opensips_fifo")

# ----- rr params -----
# add value to ;lr param to cope with most of the UAs
modparam("rr", "enable_full_lr", 1)
# do not append from tag to the RR (no need for this script)
modparam("rr", "append_fromtag", 0)

# ----- usrloc params -----
modparam("usrloc", "db_mode", 2)
modparam("usrloc", "db_url",
"mysql://opensips:opensipsrw@localhost/opensips")

# ----- uri_db params -----
modparam("uri_db", "use_uri_table", 0)
modparam("uri_db", "db_url", "")

# ----- acc params -----
/* what sepcial events should be accounted ? */
modparam("acc", "early_media", 1)
modparam("acc", "report_ack", 1)
modparam("acc", "report_cancels", 1)
/* account triggers (flags) */
modparam("acc", "failed_transaction_flag", 3)
modparam("acc", "log_flag", 1)
modparam("acc", "log_missed_flag", 2)
/* uncomment the following lines to enable DB accounting also */
modparam("acc", "db_flag", 1)
modparam("acc", "db_missed_flag", 2)

# ----- auth_db params -----
modparam("auth_db", "calculate_ha1", yes)
modparam("auth_db", "password_column", "password")
modparam("auth_db", "db_url",
"mysql://opensips:opensipsrw@localhost/opensips")
modparam("auth_db", "load_credentials", "")

# ----- domain params -----
modparam("domain", "db_url",
"mysql://opensips:opensipsrw@localhost/opensips")
modparam("domain", "db_mode", 1) # Use caching

# ----- multi-module params -----
/* uncomment the following line if you want to enable multi-domain support
in the modules (dafault off) */
modparam("alias_db|auth_db|usrloc|uri_db", "use_domain", 1)


####### Routing Logic ########


# main request routing logic

route{

if (!mf_process_maxfwd_header("10")) {
send_reply("483","Too Many Hops");
exit;
}

if (has_totag()) {
# sequential request withing a dialog should
# take the path determined by record-routing
if (loose_route()) {
if (is_method("BYE")) {
setflag(1); # do accounting ...
setflag(3); # ... even if the transaction fails
} else if (is_method("INVITE")) {
# even if in most of the cases is useless, do RR for
# re-INVITEs alos, as some buggy clients do change route set
# during the dialog.
record_route();
}
# route it out to whatever destination was set by loose_route()
# in $du (destination URI).
route(1);
} else {
if ( is_method("ACK") ) {
if ( t_check_trans() ) {
# non loose-route, but stateful ACK; must be an ACK after
# a 487 or e.g. 404 from upstream server
t_relay();
exit;
} else {
# ACK without matching transaction ->
# ignore and discard
exit;
}
}
send_reply("404","Not here");
}
exit;
}

#initial requests

# CANCEL processing
if (is_method("CANCEL")) {
if (t_check_trans())
t_relay();
exit;
}

t_check_trans();

# authenticate if from local subscriber
if (!(method=="REGISTER") && is_from_local()) {
if (!proxy_authorize("", "subscriber")) {
proxy_challenge("", "0");
exit;
}
if (!check_from()) {
sl_send_reply("403","Forbidden auth ID");
exit;
}

consume_credentials();
# caller authenticated
}

# preloaded route checking
if (loose_route()) {
xlog("L_ERR",
"Attempt to route with preloaded Route's [$fu/$tu/$ru/$ci]");
if (!is_method("ACK"))
send_reply("403","Preload Route denied");
exit;
}

# record routing
if (!is_method("REGISTER|MESSAGE"))
record_route();

# account only INVITEs
if (is_method("INVITE")) {
setflag(1); # do accounting
}

# if not a targetting a local SIP domain, just send it out
# based on DNS (calls to foreign SIP domains)
if (!is_uri_host_local()) {
append_hf("P-hint: outbound\r\n");
route(1);
}

# requests for my domain

if (is_method("REGISTER")) {
# authenticate the REGISTER requests
if (!www_authorize("", "subscriber")) {
www_challenge("", "0");
exit;
}
if (!check_to()) {
send_reply("403","Forbidden auth ID");
exit;
}

if (!save("location"))
sl_reply_error();

exit;
}

if ($rU==NULL) {
# request with no Username in RURI
sl_send_reply("484","Address Incomplete");
exit;
}

# do lookup
if (!lookup("location")) {
send_reply("404", "Not Found");
exit;
}

# when routing via usrloc, log the missed calls also
setflag(2);

route(1);
}


route[1] {
if (!t_relay()) {
sl_reply_error();
};
exit;
}


failure_route[1] {
if (t_was_cancelled()) {
exit;
}

# uncomment the following lines if you want to redirect the failed
# calls to a different new destination
##if (t_check_status("486|408")) {
## sethostport("192.168.2.100:5060");
## # do not set the missed call flag again
## t_relay();
##}
}
@]
August 30, 2009, at 06:35 PM by bogdan -
Changed lines 306-308 from:
### service number *2111 for listening the current time message - OpenSIPS will rewrite it to '''AN_time''' and send it to Asterisk
### service number *2112 for listening the current date message - OpenSIPS will rewrite it to '''AN_date''' and send it to Asterisk
### service number *2113 for accessing the echo service - OpenSIPS will rewrite it to '''AN_echo''' and send it to Asterisk
to:
## service number *2111 for listening the current time message - OpenSIPS will rewrite it to '''AN_time''' and send it to Asterisk
## service number *2112 for listening the current date message - OpenSIPS will rewrite it to '''AN_date''' and send it to Asterisk
## service number *2113 for accessing the echo service - OpenSIPS will rewrite it to '''AN_echo''' and send it to Asterisk
Changed line 310 from:
### service number *3XXX for dialling into the conference room XXX - OpenSIPS will rewrite it to '''CR_XXX''' and send it to Asterisk
to:
## service number *3XXX for dialling into the conference room XXX - OpenSIPS will rewrite it to '''CR_XXX''' and send it to Asterisk
August 30, 2009, at 06:34 PM by bogdan -
Changed lines 298-310 from:
!!!! OpenSIPS configuration
to:
!!!! OpenSIPS configuration

In this example we take the OpenSIPS default config file that provides user registration and authentication against the DB and extends the script for adding the following media oriented services:

# voicemail
## leaving a message - if the called user is not registered on OpenSIPS, the call will be forwarded by OpenSIPS (by adding '''VMR_''' prefix) to Asterisk
## listening messages -if a subscriber calls to the *1111 number, OpenSIPS will rewrite it to '''VM_pickup'' and send it to Asterisk
# announcements
### service number *2111 for listening the current time message - OpenSIPS will rewrite it to '''AN_time''' and send it to Asterisk
### service number *2112 for listening the current date message - OpenSIPS will rewrite it to '''AN_date''' and send it to Asterisk
### service number *2113 for accessing the echo service - OpenSIPS will rewrite it to '''AN_echo''' and send it to Asterisk
# conference
### service number *3XXX for dialling into the conference room XXX - OpenSIPS will rewrite it to '''CR_XXX''' and send it to Asterisk
August 30, 2009, at 06:23 PM by bogdan -
Deleted line 290:
exten => _CR_.,n,Set(LANGUAGE()=de)
August 30, 2009, at 06:22 PM by bogdan -
Added lines 226-295:
The following extensions are set for Asterisk:

# '''VMR_''' prefix indicates that the caller (identify by SIP FROM header) leaves a voicemail message to the user indicated by the RURI (after the prefix).

# '''VM_pickup''' RURI indicates that the caller (identify by SIP FROM header) accesses his own voicemailbox IVR (to listen his messages); the access is done directly, without any PIN required from Asterisk

# '''AN_notavailable''' plays the "Not Available" audio message

# '''AN_time''' plays the current time message (for the given timezone)

# '''AN_date''' plays the current time message (for the given timezone)

# '''AN_echo''' accesses the echo audio service

# '''CR_''' prefix indicates access to a conference room; the number of the room is part of the RURI, after the prefix (like CR_3322); Asterisk will perform the checks for conference room existence and for the access PIN code.



Set in ''/etc/asterisk/extensions.conf''' :
[@
[general]
static=yes
writeprotect=no

[default]

; Voicemail
exten => _VMR_.,n,Ringing
exten => _VMR_.,n,Wait(1)
exten => _VMR_.,n,Answer
exten => _VMR_.,n,Wait(1)
exten => _VMR_.,n,Voicemail(${EXTEN:4}|u)
exten => _VMR_.,n,Hangup

; Allow users to call their Voicemail directly
exten => VMS_pickup,n,Ringing
exten => VMS_pickup,n,wait(1)
exten => VMS_pickup,n,VoicemailMain(${CALLERIDNUM}|s)
exten => VMS_pickup,n,Hangup


; announcement: not available
exten => AN_notavailable,1,Ringing
exten => AN_notavailable,2,Playback(notavailable)
exten => AN_notavailable,3,Hangup

; announcement: time
exten => AN_time,1,Ringing
exten => AN_time,2,Wait(1)
exten => AN_time,3,SayUnixTime(,Europe/Bucharest,HMp)
exten => AN_time,4,Hangup

; announcement:date
exten => AN_date,1,Ringing
exten => AN_date,2,SayUnixTime(,Europe/Bucharest,ABdY)
exten => AN_date,3,Hangup

; announcement: echo
exten => AN_echo,1,Ringing
exten => AN_echo,2,Answer
exten => AN_echo,3,Echo

; Conference service
exten => _CR_.,1,Ringing
exten => _CR_.,n,Wait(1)
exten => _CR_.,n,Set(LANGUAGE()=de)
exten => _CR_.,n,MeetMe(${EXTEN:3}|Mi)


@]
August 30, 2009, at 05:59 PM by bogdan -
Added lines 177-221:

Configure the access for Asterisk to the created database (via unixodbc):
* in ''etc/odbcinst.ini''
[@
[MySQL]
Description = MySQL driver
Driver = /usr/lib/odbc/libmyodbc.so
Setup = /usr/lib/odbc/libodbcmyS.so
CPTimeout =
CPReuse =
UsageCount = 1
@]

* in ''/etc/odbc.ini''
[@
[MySQL-asterisk]
Description = MySQL Asterisk database
Trace = Off
TraceFile = stderr
Driver = MySQL
SERVER = localhost
USER = asterisk
PASSWORD = asterisk_pwd
PORT = 3306
DATABASE = asterisk
@]

* in ''/etc/asterisk/res_odbc.conf''
[@
[asterisk]
enabled => yes
dsn => MySQL-asterisk
username => asterisk
password => asterisk_pwd
pre-connect => yes
@]

* in ''/etc/asterisk/extconfig.conf''
[@
sipusers => odbc,asterisk,sipusers
sippeers => odbc,asterisk,sipusers
voicemail => odbc,asterisk,vmusers
meetme => odbc,asterisk,meetme
@]
August 30, 2009, at 05:51 PM by bogdan -
Added line 81:
Login to the '''opensips''' database (use the above login command) and run:
Changed lines 83-87 from:
alter table subscriber add column `vmail_password` varchar(8) NOT NULL default '1234';
alter table subscriber add column `first_name` varchar(25) NOT NULL default '';
alter table subscriber add column `last_name` varchar(45) NOT NULL default '';
alter table subscriber add column `email_address` varchar(50) NOT NULL default '';
alter table subscriber add column `datetime_created` datetime NOT NULL default '0000-00-00 00:00:00';
to:
> alter table subscriber add column `vmail_password` varchar(8) NOT NULL default '1234';
> alter table subscriber add column `first_name` varchar(25) NOT NULL default '';
> alter table subscriber add column `last_name` varchar(45) NOT NULL default '';
> alter table subscriber add column `email_address` varchar(50) NOT NULL default '';
> alter table subscriber add column `datetime_created` datetime NOT NULL default '0000-00-00 00:00:00';
Changed lines 90-91 from:
!!!!! Creating the Asterisk views
to:
!!!!! Creating the Asterisk tables

Create a separate database to be used by Asterisk - login as root into mysql server and run:
[@
> create database asterisk;
> GRANT ALL PRIVILEGES ON asterisk.* TO 'asterisk' IDENTIFIED BY 'asterisk_pwd';
@]

Create the Asterisk tables which are exclusively used only by Asterisk (as mysql tables):
[@
# create table for the meetme service
CREATE TABLE `meetme` (
`confno` varchar(80) NOT NULL default '0',
`username` varchar(64) NOT NULL default '',
`domain` varchar(128) NOT NULL default '',
`pin` varchar(20) default NULL,
`adminpin` varchar(20) default NULL,
`members` int(11) NOT NULL default '0',
PRIMARY KEY (`confno`)
) ENGINE=MyISAM

# create table to store the voicemail massages
CREATE TABLE `voicemessages` (
`id` int(11) NOT NULL auto_increment,
`msgnum` int(11) NOT NULL default '0',
`dir` varchar(80) default '',
`context` varchar(80) default '',
`macrocontext` varchar(80) default '',
`callerid` varchar(40) default '',
`origtime` varchar(40) default '',
`duration` varchar(20) default '',
`mailboxuser` varchar(80) default '',
`mailboxcontext` varchar(80) default '',
`recording` longblob,
PRIMARY KEY (`id`),
KEY `dir` (`dir`)
) ENGINE=MyISAM
@]

Create the Asterisk tables (as mysql views) that import the information from OpenSIPS tables:
[@
# create the asterisk users tables as a view over the OpenSIPS subscriber table
CREATE VIEW `asterisk`.`sipusers` AS select
`opensips`.`subscriber`.`username` AS `name`,
`opensips`.`subscriber`.`username` AS `username`,
_latin1'friend' AS `type`,
NULL AS `secret`,
`opensips`.`subscriber`.`domain` AS `host`,
concat(`opensips`.`subscriber`.`rpid`,_latin1' ',_latin1'<',`opensips`.`subscriber`.`username`,_latin1'>') AS `callerid`,
_latin1'default' AS `context`,
`opensips`.`subscriber`.`username` AS `mailbox`,
_latin1'yes' AS `nat`,
_latin1'no' AS `qualify`,
`opensips`.`subscriber`.`username` AS `fromuser`,
NULL AS `authuser`,
`opensips`.`subscriber`.`domain` AS `fromdomain`,
NULL AS `insecure`,
_latin1'no' AS `canreinvite`,
NULL AS `disallow`,
NULL AS `allow`,
NULL AS `restrictcid`,
`opensips`.`subscriber`.`domain` AS `defaultip`,
`opensips`.`subscriber`.`domain` AS `ipaddr`,
_latin1'5060' AS `port`,
NULL AS `regseconds`
from `opensips`.`subscriber`;

# create the asterisk voceimail users table as a view over the OpenSIPS subscriber table
CREATE VIEW `asterisk`.`vmusers` AS select
`opensips`.`subscriber`.`phplib_id` AS `uniqueid`,
`opensips`.`subscriber`.`username` AS `customer_id`,
_latin1'default' AS `context`,
`opensips`.`subscriber`.`username` AS `mailbox`,
`opensips`.`subscriber`.`vmail_password` AS `password`,
concat(`opensips`.`subscriber`.`first_name`,_latin1' ',`opensips`.`subscriber`.`last_name`) AS `fullname`,
`opensips`.`subscriber`.`email_address` AS `email`,
NULL AS `pager`,
`opensips`.`subscriber`.`datetime_created` AS `stamp`
from `opensips`.`subscriber`;

#create the asterisk voicemail aliases table as a view over the OpenSIPS dbaliases table
CREATE VIEW `asterisk`.`vmaliases` AS select
`opensips`.`dbaliases`.`alias_username` AS `alias`,
_latin1'default' AS `context`,
`opensips`.`dbaliases`.`username` AS `mailbox`
from `opensips`.`dbaliases`;
@]
August 30, 2009, at 05:37 PM by bogdan -
Changed lines 76-87 from:
*
to:
* add '''vm_password''' to be used as voicemail pin
* add '''first_name''' and '''last_name''' as subscriber name
* add '''email_address''' as subscriber's email address
* add '''datetime_created''' as timestamp of the subscriber creation.

[@
alter table subscriber add column `vmail_password` varchar(8) NOT NULL default '1234';
alter table subscriber add column `first_name` varchar(25) NOT NULL default '';
alter table subscriber add column `last_name` varchar(45) NOT NULL default '';
alter table subscriber add column `email_address` varchar(50) NOT NULL default '';
alter table subscriber add column `datetime_created` datetime NOT NULL default '0000-00-00 00:00:00';
@]
August 30, 2009, at 05:20 PM by bogdan -
Changed lines 63-77 from:
to:
In file '''/etc/opensips/opensipsctlrc''' enable the mysql backend (see '''DBENGINE''') and also configure the host where the mysql server is located, the name to be used for creating the opensips table, the read-only (ro) and read-write (rw) usernames and passwords to be created for accessing the opensips DB - see all the varaibles with '''DB''' prefix in the file.

Proceed with creation of the OpenSIPS standard database:
[@
opensipsdbctl create
@]

If you use the default values to DB host and mysql access users, you can access the DB by:
[@
mysql -h'localhost' -u'opensips' -p'opensipsrw' opensips
@]

Once the default tables are created, we need to alter the '''subscriber''' table in order to add some additional fields required by the Asterisk DB view. These changes are:
*
Added lines 80-81:

----
Added lines 84-86:


----
August 30, 2009, at 05:11 PM by bogdan -
Changed lines 55-64 from:
Considering OpenSIPS as the core SIP element of the
to:
Considering OpenSIPS as the core SIP element of the platform, the core DB will be also belonging to OpenSIPS - we will use the OpenSIPS DB to drive both OpenSIPS and Asterisk. The tables required by Asterisk (for voicemail service) will be mapped over the OpenSIPS tables.

This approach assumes two steps:
# creating the OpenSIP tables and extend them to contain also the fields (info) required by Asterisk.
# creating the mysql views over the OpenSIPS tables, in order to simulate the Asterisk tables

!!!!! Creating the OpenSIPS tables


!!!!! Creating the Asterisk views
August 30, 2009, at 05:05 PM by bogdan -
Added lines 52-55:

Only '''voicemail''' and '''conference''' services do require DB support. While the '''conference''' DB table will be exclusively be used by Asterisk (OpenSIPS does not require any information form there), the '''voicemail''' service do require a tight sharing of DB information about users between OpenSIPS and Asterisk.

Considering OpenSIPS as the core SIP element of the
August 30, 2009, at 04:41 PM by bogdan -
Added lines 8-9:
'''Version 1.0'''
Added lines 21-29:
----
!!!! Setup presentation

The following services will be offered by this integrated configuration:
* '''voicemail''' - users will get access to their mailbox; authentication will be done by OpenSIPS; while Asterisk will only provide voicemail IVR (with no access PIN);

* '''conference'''' - opensips will detect and forward calls related to conference service (based on prefixes) to Asterisk, which will provide access (pin based) to the conference rooms;

* '''announcements''' - OpenSIPS will identify the cases and types of announcements that needs to be played and will simply redirect to Asterisk.
August 30, 2009, at 04:37 PM by bogdan -
Added line 8:
----
Changed lines 15-16 from:
It is a realtime integration because both OpenSIPS and Asterisk ar provisioned in the same same time when comes to user accounts - when creating a new OpenSIPS users, automatically Asterisk will learn about it an provide and configure all necessary media services for it.
to:
It is a realtime integration because both OpenSIPS and Asterisk are provisioned in the same same time when comes to user accounts - when creating a new OpenSIPS users, automatically Asterisk will learn about it an provide and configure all necessary media services for it.
Added lines 19-20:

----
Added lines 23-39:
!!!! OpenSIPS

Install OpenSIPS 1.5 with mysql DB support (db_mysql module). if you use sources (tarballs or svn checkouts) do the following:
[@
make include_modules="db_mysql" prefix="/" all
make include_modules="db_mysql" prefix="/" install
@]

!!!! Asterisk

Use Asterisk 1.4 or 1.6.

You need to have the voicemail support with DB support, so take care and install the '''unixodbc''' support in Asterisk.

Also for the conferencing part ('''meetme''' module) you need the zaptel support ('''ztdummy''' kernel module).

----
August 30, 2009, at 04:30 PM by bogdan -
Added lines 9-16:

This tutorial presents the concept and implementation of a realtime integration of OpenSIPS SIP server and Asterisk media server.

OpenSIPS is used a SIP server - users are registering with it, it routes calls, etc - while the purpose of Asterisk is to provide a full set of media services - like voicemail, conference, announcements, etc.

It is a realtime integration because both OpenSIPS and Asterisk ar provisioned in the same same time when comes to user accounts - when creating a new OpenSIPS users, automatically Asterisk will learn about it an provide and configure all necessary media services for it.

Both OpenSIPS and Asterisk will be provisioned (for user accounts) via a shared mysql database.
August 30, 2009, at 04:16 PM by bogdan -
Changed lines 6-16 from:
!!! Realtime '''OpenSIPS - Asterisk''' Integration
to:
!!! Realtime '''OpenSIPS - Asterisk''' Integration

!!!! Scope

!!!! Prerequisites

!!!! DB Setup

!!!! Asterisk dialplan

!!!! OpenSIPS configuration
August 30, 2009, at 04:12 PM by bogdan -
Changed lines 1-6 from:
!!! Realtime OpenSIPS - Asterisk Integration
to:
!!Resources -> [[Resources.Documentation | Documentation]] -> [[Resources.DocsTutorials | Tutorials]] -> Realtime OpenSIPS - Asterisk Integration
This page has been visited {$PageCount} times.
(:toc-float Table of Content:)
----

!!! Realtime '''OpenSIPS - Asterisk''' Integration
August 28, 2009, at 11:34 AM by bogdan -
Added line 1:
!!! Realtime OpenSIPS - Asterisk Integration

Page last modified on April 24, 2013, at 07:42 PM