📜 ⬆️ ⬇️

XVB - Virtual PBX: Customization

On Habré straight month of virtual PBX.

Recall another one - XVB VirtualPBX , a boxed multi-tenant solution, with an asterisk inside.

The owner receives a system integrated into his network (self-contained box - downloaded / bought and used) providing the service of a virtual PBX. No subscriptions, running subscriber traffic across half the country, Windows servers - for someone this is still a big plus.
')
Documentation / Screenshots on the site / Video basically show standard features.

The story below will be about the possible customization that can be done by yourself.

I’ll remind you a bit about XVB VirtualPBX


A few years ago there was already an article , but since then everything has changed a lot.

for comparison, the old (by the link above) and the new interface
Reports:



Online fax:



Admin reports:



Tenant setup:



and many other changes that are consistently coming out ...



The idea has not changed:


A set of functions for most standard PBXs:



and not quite standard:



More complete list of features here .

The system is paid, but for those who are not yet completely an operator, you can pick up a free version for 10 simultaneous calls (without a limit on the number of tenants), 10 simultaneous enough for 100 phones.

After downloading and launching in the vmware player, you can basically start using it - tenants are created / phones are ringing / conversations are being written / statistics are being collected / reports are being sent. But the maneuvers for 'creativity' still remain, and the story itself will go on about them.



Simplification of creation of automatic telephone exchange, we apply configuration templates


Typically, customers roughly represent in advance what they want, so as not to force them to do the extra work, you can make your own template for the tenant.

The algorithm is as follows:

we create a new tenant; we set it up (schedule / simple IVR / example routes, etc.) and then in the menu select a user profile - save.



Copy the resulting XML file to /opt/VirtualPBX/contrib/ourtmpl.xml

and edit the variable in the configuration file /opt/VirtualPBX/etc/xvb.cfg:

ADMIN_TENANTS_TEMPLATES = -----:-----;/opt/VirtualPBX/contrib/utils/rpm/sys_update-data/ru-office.xml:RU-office;/opt/VirtualPBX/contrib/ourtmpl.xml:  


as a result, when adding a tenant, you can use the created template "Our template":



By creating a number of pre-configured PBX templates, you can greatly simplify your life and yourself. After applying the template, the time from creating a new tenant's PBX to use can be reduced to the time to configure usernames and passwords in sip phones.



Rules of the tenant's web interface templates


The installed interface templates are in the / opt / VirtualPBX / templates directory,
these are template files, almost honest html. Those that are set are reaped and
cleaned of spaces, so edit them is not very convenient. Go here and pick up the latest actual files. We correct the necessary files and put them in the right directory:

 mkdir -p /opt/VirtualPBX/templates/custom1 cd /opt/VirtualPBX/templates/custom1 ln -s . xvb.RU-Female ln -s . xvb.RU-Male cp /new/templates/*.tt /opt/VirtualPBX/templates/custom1/ xvb-ctl reload-tt 




change in the group settings template to custom1.



After that, the users in this group will take the interface from another directory.

As a result, it may turn out from the standard for example:





those who lack editing regular templates and there are developers can completely write down their interface through the API.



Hooks


Hooks are a common barley module that is called when the call starts or after it ends. By default there are several examples in:

/ opt / VirtualPBX / lib / XVBHooks


With the help of hooks, you can do anything you like before and after the call ends:
non-standard logging, various checks, setting internal variables, sms notifications, etc.

As an example, there is a module for filling data in MongoDB:

 %hooks = ( start => \&call_start, stop => \&call_stop ); # # call start hook # sub call_start { my $obj = shift; my $ast_callid = $obj->{'_AGI'}->get_variable('CHANNEL'); my $xvb_callid = $obj->{'_CDR'}->{'CALL_ID'}; $obj->{'_MONGO_DB'} = MongoDB::Connection->new(host => '127.0.0.1', port => 27017); if ( $obj->{'_MONGO_DB'} ) { my $cdrs = $obj->{'_MONGO_DB'}->xvb->cdrs; my $rc = $cdrs->insert( { ast_id => $ast_callid, timestamp => time, xvb_id => $xvb_callid, user_id => $obj->{'_USER_CREDS'}->{'ACCESS_CODE'}, callerid => $obj->{'_CDR'}->{'CALLER_ID'}, calledid => $obj->{'_CDR'}->{'CALLED_ID'}, call_type => $obj->{'_CDR'}->{'CALL_TYPE'}, node => $obj->{'_CONF'}->{'common_server_id'} } ); } } # # call stop hook # sub call_stop { my $obj = shift; my $ast_callid = $obj->{'_AGI'}->get_variable('CHANNEL'); if ( $obj->{'_MONGO_DB'} ) { my $cdrs = $obj->{'_MONGO_DB'}->xvb->cdrs; my $rc = $cdrs->remove( { ast_id => $ast_callid } ); } } 1; 


After writing the hook, you need to add it in the group settings in the / ai interface:



and allow in the configuration file /opt/VirtualPBX/etc/xvb.cfg:

HOOK = MYHOOK, MYHOOK2




Pre-handling of outgoing calls from phones


If you need to bring all the dialed numbers to a certain type or add custom processing of some numbers, you can do this in the /etc/asterisk/xvb/xvb-phone-filters.conf file. The example below lists the numbers to the e164 format:

 exten => _00XXXXXXX.,1,Goto(xvb-phones,${EXTEN:2},1) exten => _8XXXXXXXXXX,1,Goto(xvb-phones,7${EXTEN:1},1) exten => _+X.,1,Goto(xvb-phones,${EXTEN:1},1) exten => _810XXXXXXXX.,1,Set(CALLED_NUMBER=${EXTEN:3}) exten => _810XXXXXXXX.,n,Goto(xvb-phones,${EXTEN:3},digits) 


Here you can also prohibit the dialing of certain numbers (global blacklist for outgoing, for all tenants)

In the /etc/asterisk/xvb/xvb-phone-service.conf file, you can enter your service codes, for example, cost verification
call XXX:

 ; exten => _**44.,1,Set(RATE=${CURL(http://localhost/get_rate?phone=${EXTEN:4})}) exten => _**44.,n,Playback(current-rate) exten => _**44.,n,agi(d2ms.agi|${RATE}|rur) 


here the URL get_rate gives the cost of the call and below we voice it to the user.

Through the same asterisk configs, you can integrate with FMC and other useful buns over incoming calls.



SIP user registration at kamailio


By default, the system goes to asterisk but no, that does not prevent the use of kamailio as a sip-registrar.

We put the fourth kamailio, pick up the kamailio config for XVB pbx.

in the config rule address:

xvb.gw_ip = "172.16.165.129" desc "XVB GW Address" - IP asterisk

listen = MY_IP_ADDR - IP Kamalio



Rule configs asterisk. For the case if everything remains on one machine - we change the port from 5060 to 5080 and make a feast for kamilio with the friend type, send calls from it to the xvb-phones context, in /etc/asterisk/sip.conf:

[sipregistrar]
host = 172.16.165.129
port = 5060
insecure = port, invite
type = friend
context = xvb-phones


in /opt/VirtualPBX/etc/xvb.cfg add:

[Sip]
REGISTRAR_TYPE = SER
REGISTRAR_IP = 172.16.165.129
REGISTRAR_NAME = sipregistrar


in /etc/asterisk/extconfig.conf, run VPBX_SIPPEERS on VPBX_SIPPEERS_PEERS:

sippeers => odbc, xvb, VPBX_SIPPEERS_PEERS


we restart everything that is needed (or the whole system at once so that we can probably :)) and use the registration of local IPV phones via kamailio on port 5060 and asterisk for external trunks on 5080. Those who want and can go further and change the static address asterisk to use dispatcher and get clustering

As a conclusion


These examples show which way you can move in order to customize and expand XVB VirtualPBX without recourse to the help of developers if what you want in addition to what is `box 'you want to add something.

Source: https://habr.com/ru/post/270153/


All Articles