this is my twiml what I m using to connect the call-
<Response>
<Dial action="dailemptyqueueurl">
<Client statusCallbackEvent="initiated ringing answered completed" statusCallback="twilio_call_notification_handler.php" statusCallbackMethod="POST">cleint</Client>
</Dial>
<Redirect>holdmusic</Redirect>
</Response>
Twilio developer evangelist here.
This is a slight hangover from my previous advice, so sorry for that.
Firstly, when <Dial>
has an action, it will go onto that URL instead of continuing with the TwiML and going to the <Redirect>
in this case. So watch out for that.
Secondly, because we have used this technique then calls don't just end. However, you are using, I believe, Twilio Client with your agent. So, when you hangup the call on the agent end, you could make a request to your server to use the REST API to hang up the user end too.