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.

    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:



    Online Fax:



    Administrator Reports:



    Tenant Setup:



    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.



    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':



    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.



    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:





    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:



    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.

    Also popular now: