Asterisk No Answer on Queue

Need help understanding how to setup extension that only answers and sends to queue if agents are available in the queue. I purchase marketing calls from a provider and only pay for calls answered. The problem I have is when a call is sent to the sales queue it is answered (inbound call terminates on my switch). Is there a way to check the agents queue status and busy status before sending to queue?

I think this may require a very specific AGI script. Any specific hints would be appreciated.

in your queue config make sure you put

ringinuse=no

so queue ignores busy agents.

Agents should log in and log out so only agents who are ready to accept calls are on the queue in the first place. Use
AddQueueMember() and RemoveQueueMember() in your queue login/logout process to ensure that.

also you can add to your queue config:

joinempty=no
leavewhenempty=yes

which will ensure calls are not left in the queue if there are no agents logged into the queue, in which case you will need to put something in your dial plan in the event that a call cannot enter or gets tossed out of the queue under these conditions.