Using Twilio's verb, the noun allows one to specify the attribute 'url'. According to Twilio's documentation: The 'url' attribute allows you to specify a url for a TwiML document that will run on the called party's end, after she answers, but before the parties are connected. You can use this TwiML to privately play or say information to the called party, or provide a chance to decline the phone call using and . The current caller will continue to hear ringing while the TwiML document executes on the other end.

The attached patch is where I've started. It's not done yet, perhaps I might get some pointers.

My implementation is as follows. An additional parameter, $answer_gosub, is sent with $call->addDial() to the VoIP server script (Twilio/Tropo/etc). In the server script's VoipCmdDial, the $answer_gosub parameter is turned into a callback URL: /process_dial_answer/$cid/$answer_gosub. This process_dial_answer calls back to _voiptwilio_process_dial_answer() which creates a new dial script containing a single addGosub($answer_gosub).

So, you create a new script called 'call_screening' which prompts the user to press any key if he wants to accept the call. In your original script when you addDial() you pass on 'call_screening' as the sixth parameter. When the called party answers, 'call_screening' runs, and when the called party presses a key, the calls are connected. This happens invisibly to the person on the other end (caller).

I do have a couple of questions about finishing this up:

- Is this implementation proper (i.e. is there a better way?)
- Is my callback set up properly? (i.e. the proper placement in _voiptwilio_call_handler() ). Also, a new call object is created. Is this necessary, or can we use the existing call object?
- Finally, there seems to be an issue with the final call connection that I haven't been able to figure out yet. The call connects with called party and executes the script, but then when it ends it just hangs up the call and does not actually connect the users. I'm trying to work out the reason for this but if anybody has a clue I'd be grateful!

** This patch lacks proper support for Tropo/Plivo.

-Matt