0

I have this conceptual Twiml that I want the echo twimlet to provide:

<Response>
    <Record timeout="10" method="GET" action="http://someURL" />
    <Redirect>http://twimlets.com/forward</Redirect>
</Response>

My intent is to use this for outbound dialing, so that the calls that are being made are recorded. The issue is that the request parameters are sent to the echo Twimlet containing the To, From, CallerID, etc. but I really need them passed to the url in the Redirect verb. Is that possible using the echo Twimlet?

regretoverflow
  • 2,093
  • 1
  • 23
  • 45

1 Answers1

1

Twilio developer evangelist here.

You don't actually need to do this in order to record a two legged call. The <Record> verb is used to record messages, for example a voicemail service.

If you are generating these calls using the REST API, then you can set the call to record in the API call, like this (example in Node.js, I see you've answered some SO questions with Node):

var accountSid = 'AC...';
var authToken = "{{ auth_token }}";
var number1 = '+1555123456';
var number2 = '+1555456789';
var twilioNumber = '+1555654321';
var client = require('twilio')(accountSid, authToken);

client.calls.create({
    url: "http://twimlets.com/forward?PhoneNumber=" + encodeURIComponent(number2),
    to: outboundNumber,
    from: twilioNumber,
    record: true
}, function(err, call) {
    process.stdout.write(call.sid);
});

You can also give that call a statusCallBack URL that the recording will be POSTed to after the call.

If you are not generating the call from the REST API but you still want to record both sides of the call. You need to use the <Dial> verb and set to record that way. You need to create some TwiML at a URL your Twilio number points to that looks like this:

<Response>
  <Dial record="record-from-answer">
    {{ onward number }}
  </Dial>
</Response>

If you supply an action attribute to the <Dial> verb then once the call is done Twilio will POST the URL of the recording to the action.

I'm not exactly sure how you'd accomplish this with Twimlets. Ideally you want to be able to set the URL that the recording URL is sent to and save it somehow, but you'd need your own server for that. It would be possible to create any of the resulting TwiML you'd need using the echo Twimlet, but it may be better to consider your own server at this point.

Let me know if this helps at all.

philnash
  • 70,667
  • 10
  • 60
  • 88
  • Thank you. I ended up writing a small Google Apps Script to produce the necessary TWIML, and in the meantime discovered that google apps scripts are actually a very nice way to write dynamic TWIML apps since they can produce XML and take input parameters! – regretoverflow Nov 09 '15 at 18:13