how to find the agent login id associated with the extension

I have a requirement in which the caller presses and extension and the call should get routed to the the agent.
so ,

  1. I need to find whether the extension is valid or not
  2. if the xtension is valid, I need to find the agent login
  3. find if the agent is voice ready.

and then route the call to the agent.
How do I do this is composer workflow? if there any API. what are the parameters?

LIST varPlace= FindConfigObject[CFGPlace, ‘number:extension_dn|switch:switch_extension_dn_defined_on’]
if error something not valid in configuration or extension_dn is incorrect
STRING varPlaceName = TKVListGetStringValue[varPlace, ‘name’]
now it possible route to “directly” on place or get place status and get agent id from it (if somebody logged in on it)
LIST varPlaceStatus = TargetState[Cat[varPlaceName, ‘.AP’]]
STRING varAgentID = TKVListGetStringValue[varPlaceStatus, ‘agent’]
also INTEGER varAgentPlaceState = TKVListGetStringValue[varPlaceStatus, ‘state’] will provide status of the place (and the agent) if needed.