Phonebook xml

Is there a way that Asterisk creates a phonebook.xml out of the Directory entries I imported into FreePBX ?

I tried several modules, but couldn’t find out if there’s one created or do I need to do that myself ?

TIA
Marc

There is not currently one.

I guess you are saying there is none, or are you saying there more than two ?

But if there’s none is there another way to integrate a Yealink phone into the central phonebook ?

@marcc he is saying this is currently not a built in function.

It is something you would have to generate.

Unsupported, Unofficial, All that Jazz
A python script that dumps it out as json. You can process that data in to the schema of choice.

Maybe a good start?


#!/usr/bin/perl -w
02
# Quick script to hack out a directory for a mac address. I use it for the
03
# receptionist's BLF on her IP650 with sidecars.
04
use strict;
05
use Polycom::Contact::Directory;
06
use DBI;
07
 
08
# Grab the MAC address from ARGV and make a file
09
my $mac = $ARGV[0] or die "No MAC Specified\n";
10
my $contactFile = "/tftpboot/polycom/contacts/$mac-directory.xml";
11
 
12
# Create a new Empty Directory
13
my $dir = Polycom::Contact::Directory->new();
14
# Connect to the trixbox MySQL DB
15
my $dbh = DBI->connect('dbi:mysql:asterisk:localhost:3306','root','passw0rd',{ RaiseError => 1});
16
 
17
# Pull an array ref for the extensions
18
my $userAry = $dbh->selectall_arrayref("SELECT extension,name FROM users ORDER BY extension");
19
 
20
$dbh->disconnect();
21
 
22
# Set counter for speed dial index
23
my $x = 1;
24
 
25
# Loop through extensions
26
for my $a (@$userAry) {
27
# Split the trixbox name into first and last.
28
my ($fn,$ln) = split(/\s+/,$a->[1],2);
29
 
30
# My contacts are generally dirty, I'll make them look better. Some people may want
31
# to comment this out if you have people with unique capitalization.
32
$fn = ucfirst(lc($fn));
33
$ln = ucfirst(lc($ln));
34
 
35
# Insert the record into the object.
36
# I like the labels to be: extension firstname lastname "3721 Awesome Dude"
37
#  -- buddy_watching lets the polycom monitor BLF status. For this to work,
38
#     you must have feature.1.name="presence" feature.1.enabled="1" in
39
#     /tftpboot/sip.cfg
40
#  -- Check Polycom::Contact Documentation for Options
41
$dir->insert(
42
{   first_name => $fn,                  # <fn> in xml
43
last_name  => $ln,                  # <ln> in xml
44
contact    => "$a->[0]",            # <ct> in xml
45
label      => "$a->[0] $fn $ln",    # <lb> in xml
46
buddy_watching => 1,                # <bw> in xml
47
speed_index => $x,                  # <sd> in xml
48
buddy_block => 0,                   # <bb> in xml
49
auto_divert => 0,                   # <ad> in xml
50
auto_reject => 0,                   # <ar> in xml
51
 
52
},
53
);
54
$x++;
55
}
56
 
57
# Save the contact file.
58
$dir->save($contactFile);
59
 
60
1;
1 Like

He asked about the asterisk phone book which is stored in astdb

Very nice! This was exactly what I was looking for. Thanks for sharing!

Amazing. That was 2 years ago. Glad it helped but today would have looked at EPM and Phone Apps. Much more integrated and human friendly.

Reminds me of how far we have come!

Good luck.

1 Like