1

I have modified the Twilio call screening script so that it simultaneously tries several phones, and if someone preses a key to accept the call then it connects.

If this doesn't happen, or it times out, then it is sent back to a switch statement that decides what to do.

The issue I am having is being able to redirect to a Twimlet if the office is closed or there is no answer.

This si what i have so far:

switch ($DialCallStatus) {
case 'busy':
case 'no-answer':
case 'failed':
    echo '<Response><Redirect>http://twimlets.com/voicemail?Email=al@domain.co.uk&Message=http://domain.co.uk/answerphone_open.mp3</Redirect></Response>';
    break;

case 'closed':
    echo '<Response><Redirect>http://twimlets.com/voicemail?Email=al@domain.co.uk&Message=http://domain.co.uk/answerphone_closed.mp3</Redirect></Response>';
    break;

case 'completed':
    echo '<Response><Hangup/></Response>';
    break;


default:
    echo '<Response>
           //tries other phones

The switch seems to be working right as I can <say> different messages depending on the case, but the redirect doesn't work

I looked at the docs and as far as I va work out, it needs to be between tags. Wat am i doing wrong?

Thanks for your help!

PS. the URL works as its my fallback url. PPS> Didn't post the full code here, but can do if its helpful.

edit: Errors

In my dashboard I get the following error:

<Response>
<Redirect>http://twimlets.com/voicemail?Email=al@dallasmatthews.co.uk&Message=http://dallasmatthews.co.uk/twilio/answerphone_closed.mp3</Redirect>
</Response>
Parse error found on line 1 of the Raw Response

My raw XML looks like this:

<Response><Redirect>http://twimlets.com/voicemail?Email=al@DOMAIN.co.uk&Message=http://DOMAIN.co.uk/twilio/answerphone_closed.mp3</Redirect></Response>
al_manchester
  • 220
  • 1
  • 12
  • Twilio evangelist here. Your TwiML looks correct. Are there any errors showing up in your API monitor (https://www.twilio.com/user/account/developer-tools/app-monitor)? Also are you setting the content-type of the response to application/xml? – Devin Rader Dec 05 '13 at 15:37
  • Hi Devin, thanks for your help (I recognise you from some of the other Twilio posts on here!). The header is set as `header("content-type: text/xml");` (in a PHP file). I tried changing to 'application/xml' but still got an error. I'll update my answer with the error. – al_manchester Dec 05 '13 at 19:16

1 Answers1

2

Did it!

I read over this stackexchange post and the clever author worked it out.

The & in the URL should have been &amp; to make it work.

Hope this helps someone else

Community
  • 1
  • 1
al_manchester
  • 220
  • 1
  • 12