Solved

Asterisk how to monitor database

Posted on 2011-09-14
8
657 Views
Last Modified: 2012-08-13
Hello,

My customer has an Asterisk 1.4. for Voip with X-Lite client.

He wants me to develop a Windows based Crm so as when there is an incoming call on a Pc, the Crm would find the customer automatically (by finding the incoming telephone number in the database of the Crm).

I can see 2 ways to solve this:

1.to constantly monitor the Asterisk database and get the actual phone number from it
in this case I need some guidance about the database structure and what tables to check

2.To get the information from X-Lite somehow

Maybe there are other ways I haven't thought about.
Please help me with this

Thank you


0
Comment
Question by:starhu
8 Comments
 
LVL 39

Expert Comment

by:noci
Comment Utility
Hm. asterisk can write the call detail records to any database / flat file you like.
So that is more or less up to you. to decide how:

cdr engines are there for: postgresql, mysql, syslog, sqlite, odbc, flatfile.

This might be usefull too.
http://www.loudhush.ro/tools/AsteriskCDRInspector.html

0
 

Author Comment

by:starhu
Comment Utility
How can I check what database uses the existing Asterix? I am a newbie in Linux
0
 
LVL 39

Expert Comment

by:noci
Comment Utility
First asterisk != linux.
In general config files in linux are kept /etc/..  but that may be different.
Most configuration files are normal ascii files that can be read.

In the asterisk configuration (mostly /etc/asterisk ) you have a number of cdr*.conf files.
and in modules.conf one of the modules is enabled.
(or rather no disabled).

Tools to read ascii files are 'less' or 'more'...
0
 
LVL 25

Expert Comment

by:Ron M
Comment Utility
There are several ways to do this...but having agent software poll the DB is going to be very costly the more users you have.

Essentially you need to get ..either the phone number to the client, the complete record, or a path to get to the customer record.

I already do something similar to this on my system, so i'll give you a basic run down of how it works on my end.   Then i'll give you a much simpler.."quick and dirty" method.

Agent -
1.  Agent logs into agent software with user/pass, the extension for their machine is already prefilled from settings.
2.  Agent software sends a "timestamp" update to an agent table (mysql) on the Asterisk server every 6 seconds, while they are in "ready" mode.
3.  Agent software has a TcpClientListener running that only accepts connections from the Asterisk server on port 5039.
4.  Agent recieves "INCOMING:${tableid}/${recordid}" so that it can pull a record immediately upon recieving a call.
5.  Agent goes into status "not ready" until record is released.

Customer -
1.  Customer calls in.
2.  Asterisk attempts to lookup the customer record by phone number storing the table ID and record ID to variables if it finds it.
    2a.  If it's not found, the customer is prompted to enter the phone associated with their account and another lookup is attmpted.
    2b.  If not found after two tries they go to operators group
3.  If the customer record is found, Asterisk polls the agent table for all agents who's timestamp is greater than the current time plus (-) negative 6 seconds and whose "timeinstatus" is the oldest.
    3a.  If Agent is not available customer remains in queue looping until an Agent is free.
4.  Asterisk uses the Extension retrieved from the agent table to get the IPaddress ....using ${SIPPEER(${agentexten}:ip)})
5.  Asterisk runs netcat to send the information to the listening client app  ...System(nc ${AGENTIPADDRESS} 5039 <<< "INCOMING:${tableid}/${recordid}")



If all that is too tough for you, then try this method...
1. Asterisk recieves a call....
2. Asterisk chooses agent...(for example agent 3002)
3. Asterisk writes a file to a Samba share...    \\server\share\3002.txt   ..inside the file is the customer phone number
4. Each agent client is polling the samba share for a file that matches their own extension.  When they find it, they read the number inside of it, then delete the file,  and then search the db for the number.  
5. When they release the record they update the agent table to be "ready" again.

There other methods to acheive the same results... I suppose it depends on your expertise and resources and development time allowed.

Another method is to poll the AMI (Asterisk Manager Interface), service running on Asterisk...there are even .Net classes you can use to communicate with it.
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:starhu
Comment Utility
xuserx2000: My customer uses a Linux Server for Asterix and Windows clients for X-Lite.

Can I get the incoming information directly from X-Lite?
0
 
LVL 39

Accepted Solution

by:
noci earned 250 total points
Comment Utility
How about running an jabber server and have asterisk log the message in a jabber group.
(Jabber is the core for many messaging systems, googles, facebook etc.).

http://www.voipphreak.ca/2008/01/29/asterisk-jabber-xmpp-basic-setup-tutorial/
https://wiki.asterisk.org/wiki/display/AST/Jabber+in+Asterisk

And for some inspiration:
http://www.youtube.com/watch?v=PrAlikkTu9M


As jabber server ejabberd is quite easy to setup & manage.
0
 
LVL 12

Assisted Solution

by:hfraser
hfraser earned 250 total points
Comment Utility
Asterisk has an api (called AMI) that allows you to manager the system from external apps, and this might provide you with the interface you need. You can also configure it to notify your CRM application using the inbound call plans. This page has lots of examples of how to do this:

http://www.voip-info.org/wiki/view/Asterisk+call+notification

Finally, have a look at applications like AtserCC and AsterCRM for PHP-based complete solutions that you could tweak to meet your requirements, rather than re-inventing the wheel from scratch.
0
 

Author Closing Comment

by:starhu
Comment Utility
it didn't completely solve my problem
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

SSH (Secure Shell) - Tips and Tricks As you all know SSH(Secure Shell) is a network protocol, which we use to access/transfer files securely between two networked devices. SSH was actually designed as a replacement for insecure protocols that sen…
I recently purchased a Bluetooth headset called the Music Jogger (model BSH10). The control buttons on it look like this: One of my goals is to use it as the microphone and speakers for Skype calls. In that respect, it works well. However, I …
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now