P
P
pcdesign2015-04-18 12:47:24
freepbx
pcdesign, 2015-04-18 12:47:24

How to teach Dial to use Follow me?

There is some context in the file: /etc/asterisk/extensions_custom.conf

exten => s,1,Answer
exten => s,n,Wait(1)
exten => s,n,Dial(SIP/204,20,m(default)tw)

Number 204 has a registered mobile phone in followe me.
How to make followe me count when calling?
And to call not only vulture, but also a mobile phone.
It is clear that you can prescribe for each case:
exten => s,n,Dial(SIP/trunk_name/7909xxxxxxx,40,m(default)tw)

But it's very inconvenient. The numbers are constantly changing, and in general ...
Are there any other ways?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
pcdesign, 2015-04-23
@pcdesign

Invented the bicycle.
I wrote a perl module that accesses the MySQL database and pulls out the necessary information from there:
follow me mobile number and current track.

#===============================================================================
#
#         FILE: followme.pm
#
#  DESCRIPTION: Модуль, который выдает текущий транк на исход, а так же выдает
#                               номер мобильного в follow me
#
#        FILES: ---
#         BUGS: ---
#        NOTES: ---
#       AUTHOR: YOUR NAME (),
# ORGANIZATION:
#      VERSION: 1.0
#      CREATED: 04/22/2015 11:58:36 AM
#     REVISION: ---
#===============================================================================

use strict;
use warnings;
use DBI;

package Followme;

our $dbh_ast = 
DBI->connect( 'dbi:mysql:dbname=asterisk;host=localhost', 'dbuser', 'pass' ) or die;

sub new {
    my ( $class, %self ) = @_;
    bless \%self, $class;
    return \%self;
}

sub get_followme {
    my $self = shift;
    my $ext  = $self->{ext};
    my $sql  = 'SELECT `grplist`  FROM `findmefollow` WHERE `grpnum` 
                           LIKE ? AND `grplist` LIKE ?';
    my ($followme_phone) = $dbh_ast->selectrow_array( $sql, undef, $ext, $ext . '-%' );
    if ($followme_phone) {
        $self->{followme_phone} = substr $followme_phone, 5, -1;
        return $self->{followme_phone};
    }
    else {
        return undef;
    }
}

sub get_current_trunk {
    my $self = shift;
    my $sql  = 'SELECT t.name, t.dialoutprefix
                           FROM  `outbound_route_trunks` o,  `trunks` t
               WHERE t.disabled LIKE  "off"
                           AND o.trunk_id = t.trunkid
                           ORDER BY o.seq ASC 
                           LIMIT 0 , 1';
    my ( $trunk_name, $dialoutprefix ) = $dbh_ast->selectrow_array($sql);
    $self->{dialoutprefix} = $dialoutprefix;
    return $trunk_name.'/'.$dialoutprefix.$self->{followme_phone};
}

1;

And it's used like this:
use Followme;
my $f = Followme->new( ext => "100" );
if ( $f->get_followme() ) {
    my $followme = $f->get_current_trunk();
    $AGI->exec( 'Dial', 'SIP/' . $followme . ',40,m(default)tw' );
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question