A client needed to do Click2Dial calls from custom CRM application. The Agent API permits pausing agent session (external_pause method) and launching the call (external_dial method) and the Non-Agent API method add_lead permits inserting a new lead, but the add_lead method is not so easy to use, because the list_id must be passed on to the method.
I ended up doing some changes to Agent API to add a new method (external_dial_lead) to insert a lead and generate a call in one step. You can check the following issue in Mantis for more details on the implementation:
http://www.vicidial.org/VICIDIALmantis/view.php?id=241
There have been many changes in api.php since I implemented this feature, so the code is quite outdated now. I am planning to update the patch in a few weeks time, and who knows maybe we can still get it into 2.2. A client is actively using this feature, and I would implement it a bit differently after observing the actual usage patterns. I would keep the steps for inserting leads and dialing separate, so that an option to repeat a call to the same lead could be implemented in the external applications.
I would just implement an alternative add_lead method that does not require the list_id argument. (The original add_lead method requires the list_id and this piece of information is not readily available to external applications. It seems more sensible to me to avoid giving direct access to vicidial tables from external applications, in an ideal world all accesses should be through controlled API calls.) The alternative method can receive the agent_user as an argument and check Manual Dial List of the actual campaign of the agent_user and add the lead to this list so that it does not require that the external application pass the list_id.