Call Routing Using Manager API?

Hi All,

I am to write an application that is supposed to make decision, which agent to route an incoming call. For example, for an incoming call in a queue, rather than asterisk making decision which agent to give this call. I want my application to tell asterisk which agent to give this call to.

PS: I am fairly new to telephony/asterisk domain.

I am thinking of one way i.e. using asterisk manager API.
My questions are

  1. How do I make asterisk wait until my application is making a decision?
  2. How do I get list of free agents using AMI?
  3. What AMI command I should give asterisk to route queued call to certain agent?

Is there any better/optimized way to accomplish my goal.

Thanks,
MAbbas