Twilio evangelist developer is here.
I think you might have too complicated things in line. In fact, you can provide a message and get together as part of the initial call without having to dial and ultimately connect the two calls.
Here's how:
Your incoming TwiML call should look like this:
<Response> <Dial action="/call_complete" timeout="30"> <Number url="/whisper"> ONWARD DIAL NUMBER </Number> </Dial> </Response>
Providing the noun <Number> URL will play the TwiML content of that URL before the two calls are connected. You can use <Gather> here to make sure the user answers the call, and not to their voicemail system:
/whisper <Response> <Gather numDigits="1" timeout="10" action="/gather_result"> <Say voice="alice">You are receiving a call, press any key to accept</Say> </Gather> <Hangup/> </Response>
/gather_result needs to determine if the key is pressed or not. If it was pressed, we proceed to the call, which we can make with an empty answer, since this returns control to the original <Dial> . If the number has not been pressed, we end this end, which forces the original <Dial> to complete and direct it to the action attribute. (I'm not sure what language you work in, but here's some Rubyish pseudo code)
/gather_result <Response> if params["Digits"] and params["Digits"].empty? <Hangup/> end </Response>
/call_complete then called after the completion of the <Dial> action. If the call status at this point is “completed” or “answered”, the user picked up the call and answered the whisper correctly, and we can hang up. If this is something else, we will redirect our call to our answering machine.
/call_complete <Response> if params["DialCallStatus"] == "completed" or params["DialCallStatus"] == "answered" <Hangup/> else <Say voice="alice">The call could not be answered this time, please leave a message</Say> <Record action="/record_complete" /> end </Response>
Then finally your action /record_complete can do everything you need with the record url and hang up the call.
/record_complete <Response> <Hangup/> </Response>
This can be achieved using Twimlets, as described in this blog post . Let me know if that helps at all.