XVB - Virtual PBX: Customization
On a habr directly a month of virtual automatic telephone exchanges.
Recall another one - XVB VirtualPBX , a boxed multi-tenant solution, with an asterisk inside.
The owner receives a system integrated into his network (a self-sufficient box - downloaded / bought and used) that provides a virtual PBX service. 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 the standard features.
The story below will be about the possible customization that you can do for yourself.
There was already an article a few years ago , but since then things have changed a lot.
The idea has not changed:
A set of functions is standard for most exchanges:
and not quite standard:
A more complete list of features is here .
The system is paid, but for those who are still not quite an operator, you can pick up the free version locked for 10 simultaneous calls (no limit on the number of tenants), 10 simultaneous enough for ~ 100 phones.
After downloading and running in the vmware player, you can basically start using it - tenants are created / phones are called / conversations are written / statistics are collected / reports are sent. But maneuvers for 'creativity' still remain, actually about them the story will go further.
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 this:
create a new tenant, configure it (schedule / simple IVR / example routes, etc.) and then select the user profile in the menu - save.
![](https://habrastorage.org/files/435/bbb/eae/435bbbeae5c241ed89ae81378375c02e.png)
copy the received XML file to /opt/VirtualPBX/contrib/ourtmpl.xml
and edit the variable in the configuration file /opt/VirtualPBX/etc/xvb.cfg:
as a result, when adding a tenant, you can use the created template 'Our template':
![](https://habrastorage.org/files/fdf/3d0/bff/fdf3d0bff7964f7698e5d6b6d36ac419.png)
By creating a number of pre-configured PBX templates, you and your clients can greatly simplify their lives. After applying the template, the time from creating a PBX of a new tenant to the start of use can be reduced to the time of setting up logins / passwords in sip phones.
Installed interface templates are in the / opt / VirtualPBX / templates directory,
these are template files, almost honest html. Those that are installed are cleared and
cleaned of gaps, so editing them is not very convenient. We go here and pick up the latest relevant files. We correct the necessary files and put them in the necessary directory:
change the template in the group settings to custom1.
![](https://habrastorage.org/files/2fd/40a/03c/2fd40a03cc6644829c69ab43a456c58b.png)
After that, the users included in this group will take the interface from another directory.
As a result, from the standard one it can turn out, for example, the following:
![](https://habrastorage.org/files/601/22e/94d/60122e94d9d345908fae65fcfea34939.png)
those who do not have enough edits for regular templates and there are developers who can completely file their interface through the API.
Hooks are a regular pearl module that is called when a call starts or after it ends. By default, there are several examples in:
With the help of hooks, before and after the call, you can do anything:
custom logging, various checks, setting internal variables, sms notifications, etc.
As an example, there is a module for uploading data to MongoDB:
After writing the hook, you need to add it in the group settings in the / ai interface:
![](https://habrastorage.org/files/61f/7b0/060/61f7b0060c764c069f87451d0b08c738.png)
and enable it in the /opt/VirtualPBX/etc/xvb.cfg configuration file:
If you want to bring all dialed numbers to a specific 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 converts the numbers to e164 format:
Here you can also prohibit the dialing of certain numbers (the global black list for outgoing
calls , for all tenants). In the /etc/asterisk/xvb/xvb-phone-service.conf file, you can register your service codes, for example, checking the cost of a
call to XXX:
here, the cost of the call is given at the get_rate URL, and below we give it to the user.
Through regular asterisk configs, you can do integration with FMC and other useful buns over incoming calls.
By default, the system goes to asterisk but does not interfere with using kamailio as a sip-registrar.
We put the fourth kamailio, we take the kamailio config for XVB pbx.
edit the address in the config:
Edit asterisk configs. For the case if everything remains on the same 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:
in /opt/VirtualPBX/etc/xvb.cfg add:
in /etc/asterisk/extconfig.conf, edit VPBX_SIPPEERS on VPBX_SIPPEERS_PEERS:
we restart everything that is needed (or the whole system right away for sure :)) and use the registration of local sip phones through kamailio on port 5060 and asterisk for external trunks on 5080. Those who wish and can know how to go further and change the asterisk static address to use dispatcher and get clustering.
The above examples show which way you can move in order to customize and expand the capabilities of XVB VirtualPBX without resorting to the help of developers if, in addition to what is a `box`, you want to add something.
Recall another one - XVB VirtualPBX , a boxed multi-tenant solution, with an asterisk inside.
The owner receives a system integrated into his network (a self-sufficient box - downloaded / bought and used) that provides a virtual PBX service. 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 the standard features.
The story below will be about the possible customization that you can do for yourself.
Let me remind you a bit about XVB VirtualPBX
There was already an article a few years ago , but since then things have changed a lot.
for comparison, the old (from the link above) and the new interface
Reports:
![](https://habrastorage.org/files/72b/4ac/ff1/72b4acff1c964925962ae45f06bd9e43.png)
Online Fax:
![](https://habrastorage.org/files/8c2/a4d/7f4/8c2a4d7f4c294601bebc2c8ff9d06ae7.png)
Administrator Reports:
![](https://habrastorage.org/files/3a1/1f7/e2b/3a11f7e2b9f9454a87b266ae29cd7ff2.png)
Tenant Setup:
![](https://habrastorage.org/files/e79/886/b49/e79886b4904743968f92af05145a63c0.png)
and many other changes that are steadily coming out ...
![](https://habrastorage.org/files/72b/4ac/ff1/72b4acff1c964925962ae45f06bd9e43.png)
Online Fax:
![](https://habrastorage.org/files/8c2/a4d/7f4/8c2a4d7f4c294601bebc2c8ff9d06ae7.png)
Administrator Reports:
![](https://habrastorage.org/files/3a1/1f7/e2b/3a11f7e2b9f9454a87b266ae29cd7ff2.png)
Tenant Setup:
![](https://habrastorage.org/files/e79/886/b49/e79886b4904743968f92af05145a63c0.png)
and many other changes that are steadily coming out ...
The idea has not changed:
- Web admin to manage tenants / group settings.
- system tuning with standard asterisk / kamailio configs, additional modules.
- the tenant configures everything via the web.
A set of functions is standard for most exchanges:
- IVR
- call recording
- smart call routing
- the ability to integrate with external CRM systems
- missed notifications / voice mail
- call statistics
- schedule
- queues with different dialer strategies
- black / white lists
- short numbering
- phone book
- API
and not quite standard:
- full call history (where the user was at each moment of the call)
- tracking calls via google analytics / cdr / realtime panel / events asterisk / http hooks
- one-touch call transfer without breaking the conversation (from mobile to landline and vice versa)
- ability to save / quick configuration recovery
- click2call out of the box
- autoinformer out of the box
- out of the box predictive dialing
- TTS out of the box
A more complete list of features is here .
The system is paid, but for those who are still not quite an operator, you can pick up the free version locked for 10 simultaneous calls (no limit on the number of tenants), 10 simultaneous enough for ~ 100 phones.
After downloading and running in the vmware player, you can basically start using it - tenants are created / phones are called / conversations are written / statistics are collected / reports are sent. But maneuvers for 'creativity' still remain, actually about them the story will go further.
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 this:
create a new tenant, configure it (schedule / simple IVR / example routes, etc.) and then select the user profile in the menu - save.
![](https://habrastorage.org/files/435/bbb/eae/435bbbeae5c241ed89ae81378375c02e.png)
copy the received 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':
![](https://habrastorage.org/files/fdf/3d0/bff/fdf3d0bff7964f7698e5d6b6d36ac419.png)
By creating a number of pre-configured PBX templates, you and your clients can greatly simplify their lives. After applying the template, the time from creating a PBX of a new tenant to the start of use can be reduced to the time of setting up logins / passwords in sip phones.
Edit tenant web interface templates
Installed interface templates are in the / opt / VirtualPBX / templates directory,
these are template files, almost honest html. Those that are installed are cleared and
cleaned of gaps, so editing them is not very convenient. We go here and pick up the latest relevant files. We correct the necessary files and put them in the necessary 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
- symlinks need to be done since the templates are tied to the tenant's language settings.
- xvb-ctl is a utility for some management. reload-tt - clear the template cache.
change the template in the group settings to custom1.
![](https://habrastorage.org/files/2fd/40a/03c/2fd40a03cc6644829c69ab43a456c58b.png)
After that, the users included in this group will take the interface from another directory.
As a result, from the standard one it can turn out, for example, the following:
![](https://habrastorage.org/files/601/22e/94d/60122e94d9d345908fae65fcfea34939.png)
those who do not have enough edits for regular templates and there are developers who can completely file their interface through the API.
Hooks
Hooks are a regular pearl module that is called when a call starts or after it ends. By default, there are several examples in:
/ opt / VirtualPBX / lib / XVBHooks
With the help of hooks, before and after the call, you can do anything:
custom logging, various checks, setting internal variables, sms notifications, etc.
As an example, there is a module for uploading data to MongoDB:
%hooks = (
start => \&call_start,
stop => \&call_stop
);
## call start hook#subcall_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#subcall_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:
![](https://habrastorage.org/files/61f/7b0/060/61f7b0060c764c069f87451d0b08c738.png)
and enable it in the /opt/VirtualPBX/etc/xvb.cfg configuration file:
HOOK = MYHOOK, MYHOOK2
Pre-processing outgoing calls from phones
If you want to bring all dialed numbers to a specific 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 converts the numbers to 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 (the global black list for outgoing
calls , for all tenants). In the /etc/asterisk/xvb/xvb-phone-service.conf file, you can register your service codes, for example, checking the cost of a
call to 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 cost of the call is given at the get_rate URL, and below we give it to the user.
Through regular asterisk configs, you can do integration with FMC and other useful buns over incoming calls.
Removal of registration of SIP users on kamailio
By default, the system goes to asterisk but does not interfere with using kamailio as a sip-registrar.
We put the fourth kamailio, we take the kamailio config for XVB pbx.
edit the address in the config:
xvb.gw_ip = "172.16.165.129" desc "XVB GW Address" - IP asterisk
listen = MY_IP_ADDR - IP camalio
Edit asterisk configs. For the case if everything remains on the same 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, edit VPBX_SIPPEERS on VPBX_SIPPEERS_PEERS:
sippeers => odbc, xvb, VPBX_SIPPEERS_PEERS
we restart everything that is needed (or the whole system right away for sure :)) and use the registration of local sip phones through kamailio on port 5060 and asterisk for external trunks on 5080. Those who wish and can know how to go further and change the asterisk static address to use dispatcher and get clustering.
In conclusion
The above examples show which way you can move in order to customize and expand the capabilities of XVB VirtualPBX without resorting to the help of developers if, in addition to what is a `box`, you want to add something.