Reputation: 25
I've inherited a web app that is currently using the TwilioRestClient in C# and JavaScript. I need to be able to keep an entire recording of the call and any transfers made for the duration of the call.
For inbound calls, we immediately start a conference and maintain that same conference through all transfers - this keeps the recording together and is working fine.
For outbound calls, the existing logic first calls the number, the caller and call recipient speak, and then a transfer may need to be performed. The transfer process puts the recipient into a conference, then the caller initiates a call to a third number, and lastly all three are joined into the conference. This is creating 3 legs to the call with 3 different recordings.
How can I start a conference and immediately dial out to the desired number? Can this be done with a single Twiml response or would I have to possibly perform the dial out after the conference starts using the statusCallback event?
Upvotes: 2
Views: 881
Reputation: 73029
Twilio developer evangelist here.
For an outbound call you can return the TwiML for a conference for your dialler and then make another outbound call that will drop the answerer into the conference too.
You can do this using the conference participant resource in the REST API. Using one REST API call you can add a new participant to a conference. You can make this API call then return the Conference TwiML in the same request.
In C# it would look a bit like this:
const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
const string authToken = "your_auth_token";
TwilioClient.Init(accountSid, authToken);
var participant = ParticipantResource.Create(
from: new Twilio.Types.PhoneNumber("+15017122661"),
to: new Twilio.Types.PhoneNumber("+15017122661"),
pathConferenceSid: CONFERENCE_FRIENDLY_NAME
);
You can use the friendly name (the name you put between <Conference>
tags in the TwiML) to refer to the conference.
Upvotes: 1