DB based info for caller priority into queue

We’ve a database of customers, ran under PHP/MySQL. Every time one of them call us, he or she is serviced by one of our agents. They run an Elastix based inbound call-center, that allow us embeed a web app we designed for this. Web app is triggered when the call is sent out the queue to the agent.

Every time a customer calls, we record some customer order info and increment a calls counter field in the customer’s record in the DB. We’d like to give queue priority to those -VIP- customers whom have a larger number of calls (orders), over the ocassionally callers.

We want to be able to:

  1. get the caller id in PBX
  2. run some kind of (asterisk/freepbx ??) app/script, querying for customer’s record in DB and getting his/her number of calls (orders), based on customer’s caller ID
  3. Set the caller’s priority (increase it) based on the number of previous calls
  4. Proceed to queue the call (to a common or to a prioritized queue, whatever).
  5. Be the customer served before the others.
  6. Trigger our own app from elastix, when agent gets free, and collect new order…

I appreciate any help on this. May be someone may point me into the right direcion.

Thanks, regards.
Fabio

We can’t answer for Elastix, but the queue application takes a priority parameter, and lower priority items are only eligible when higher priority ones are not present. (Some details of the inner workings can mean calls are sometimes temporarily ineligible, so the priority can get violated.