问题
I have my twiml as such:
<Response>
<Dial timeout="12">
<Client>Robbie</Client>
</Dial>
<Say>
The person you are trying to reach is currently unavailable. Please leave a message at the beep.
</Say>
<Record action="/voicemail/fdasjhklewu/" maxLength="90" method="GET" timeout="7"/>
</Response>
Here twilio tries to reach the client to connect and incoming call and then if there's no response, it goes to voicemail.
However, if I answer and then hangup, it still goes to voicemail. How can I hangup and not goto voicemail?
回答1:
Twilio developer evangelist here.
You can actually achieve what you want, but in a slightly different way.
If you pass an action to your <Dial>
like this:
<Response>
<Dial action='/after_dial'>
<Client>Robbie</Client>
</Dial>
</Response>
Then once the call completes, you'll need something to deal with a callback to that action. Here is an example in Ruby with Sinatra (though you can do this with whatever language you want):
post '/after_dial' do
content_type 'text/xml'
if ['busy', 'no-answer', 'failed', 'canceled'].include?(params['DialCallStatus'])
"<Say>
The person you are trying to reach is currently unavailable. Please leave a message at the beep.
</Say>
<Record action="/voicemail/fdasjhklewu/" maxLength="90" method="GET" timeout="7"/>"
else
"<Hangup/>"
end
end
The DialCallStatus
parameter tells you what happened to the call, so if it was busy, missed, canceled or failed for any reason you can go to voicemail, otherwise the call was completed and you can just hangup.
Let me know if this helps at all.
回答2:
I don't think there is a way to do what you want.
Twilm is executed in the order it comes in.
What you would want to do is specify a call back page for the dial.
Then if it was completed you would want to hangup
If it was not completed you would then do the voice mail.
He is the example from the website. Remember you will use the same logic if it is a client or a phone
https://www.twilio.com/docs/howto/voicemail
来源:https://stackoverflow.com/questions/28463312/twilio-twiml-dont-record-after-client-hangs-up