Dual-Channel Recording Using Twilio? - twilio

I have been trying to record 2 channels using Twilio by setting up a conference call. This is what I have implemented:
<Response>
<Say>Your call is being recorded</Say>
<Dial record="record-from-answer-dual" timeLimit="330" trim="trim-silence">
<Conference waitUrl="">
Conference Room
</Conference>
</Dial>
</Response>
How it works is that I will call the twilio number first. then add another number to the call so its 3 way, with the twilio number being silence. I found I am not getting 2 separate channel between the 2 speaker. Instead, I think Twilio is using itself as one of the channel, and the original caller as the other. Is there a way to configure so that we can get triple channel to include or a way to set it so it doesn't consider itself as a channel?

Twilio developer evangelist here.
When you use record-from-answer-dual with a <Conference> the documentation says:
If a dual-channel recording option is used for a <Dial> with a nested <Conference>, the resulting recording file will have two channels. The parent leg (inbound caller) is represented in the first channel. The second channel includes the audio coming downstream from the conference.
There is not currently a way to make a triple channel recording.

Related

Testing our IVR - Twilio send_digits

I am building a machine to bounce with our company's IVR. For that I need a degenerated IVR and specifically I wish to have it receiving a call and sending_digits to the IVR.
I could not figure out how to send_digits without first calling the other party.
Using python for this matter.
Can someone spill light on this?
Twilio developer evangelist here.
I think you are asking how to receive a call on a Twilio number and play DTMF tones. If so, you can do that using the <Play> TwiML element.
<Play> normally expects a URL that plays an audio file. However, you can also pass the digits attribute which will direct Twilio to send the DTMF tones down the line.
You can add any digits you like as well as pauses using the w character. A single w will wait for half a second and you can use multiple in a row. For example this TwiML will direct Twilio to send the digits 123 then wait 1 second, then send 456, then end the call.
<Response>
<Play digits="123ww456"/>
</Response>

Twilio Stream only when the call has been received

I am using twiml bin attached to one of my twilio numbers.
When a person calls that number it should be able to dial multiple numbers. I want to stream the call only when the call has been picked up. There can be multiple ongoing streams associated with a twilio number.
<Response>
<Start>
<Stream track="both_tracks" url="wss://XXXX.ngrok.io /twilio-stream">
</Stream>
</Start>
<Dial answerOnBridge="true" >
<Number>+91XXXXXXXXX</Number>
<Number>+91XXXXXXXXX</Number>
</Dial>
</Response>
The above twiml starts the stream as soon as the number is dialed. I want it to start the stream only when the call is received at the other end.
Unfortunately, there isn't a way to do this today, without REST API endpoint control.
You can use the REST API Calls resource to initiate calls intead. The approach you are taking doesn't work very well when the dialed parties are mobile end-points in poor coverage areas and/or devices with voicemail enabled.

How to detect Touch-tones (DTMF) in a Twilio video room

After following this document I can successfully add PSTN callers to a video room (Small Room type). What I haven't been able to do is to detect DTMF tones from the person calling in.
I tried two different approaches, both have failed
1) The one that I used before with a different provider and worked, but not with Twilio, was to have one of the other users in the room (not the PSTN caller but a javascript client) detect the DTMF client-side. This doesn't work with twilio because it sounds to me like twilio is manipulating the audio stream to remove the DTMFs before they reach the other users in the room (when the PSTN caller presses a number, you only hear a short "click" on the other side)
2) Inspired by this answer, I tried to reply with a TWIML
<Response>
<Connect>
<Room>my-room</Room>
</Connect>
<Gather input="dtmf">
</Gather>
</Response>
This would not be ideal since it wouldn't detect the DTMF while in the room; you would have to leave the room, but I tried it anyway to see if I could come up with a way to terminate the call to move on to the gather verb like in the linked answer. It looks like the call doesn't move to the gather part after the room ends (i tried completing the room and the PSTN call immediately ends)
Are there any other approaches that anyone has used for this? The simplest to me would be a way to tell twilio not to remove the DTMFs from the audio stream so my solution #1 would work, but I'm open to other ideas maybe leveraging twilio's gather
Twilio developer evangelist here.
It doesn't look like it's currently directly possible to detect DTMF tones in a phone call that has been connected to a video room.
One possibility is to use the new Media Stream capability to direct the live audio to your own server to detect the tones.
I have asked the team to see if there are other options though.

Transfer Enqueued Call to Conference Using Twilio

Imagine there is an incoming call currently enqueued via Twilio.
I want to transfer this call a new conference line.
Currently, my app "updates" the call with a redirect URL that responds with the following TwiML.
Unfortunately, it just hangs there, listening to music, and I never enter the conference.
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Dial>
<Conference endConferenceOnExit="true" startConferenceOnEnter="true" waitUrl="http://example.com/music">
{{CallSid}}
</Conference>
</Dial>
</Response>
Note that the {{CallSid}} is dynamically updated with the call identifier (aka Call SID). Also, I have not tried this with a second phone (because maybe it won't connect to the conference line until there is more than one person?)
Twilio developer evangelist here.
First up, your question in parentheses was indeed correct, a conference will not start with one person in, so will just play the hold music until someone else joins.
Secondly, once you added a second call you were still hearing hold music. However, for the <Conference> identifier, you said you were using the CallSid. That identifier is unique per call leg, so each of your calls would have different CallSids and thus would join different conference calls. To first ensure that this is the issue, I would test your code with a static identifier for the conference (<Conference>Test</Conference> for example). If you can get callers talking together like that, then you will need to find a way to identify a conference independent of the individual CallSids and use that as the identifier so that you can join the calls together.
Let me know if that helps at all.

Clarification on Twilio's Record and Transcribe Feature

I'm looking at Twilio's API documentation for Record and wanted some clarification.
1) I saw that transcribe currently is limited to recordings of 2 minutes, so if I set Transcribe to true, if the call goes on longer than 2 minutes there won't be a transcript but the recording will be saved?
2) Is it possible to just dial a number and record the audio without having to be connected to an "agent"?
Twilio developer evangelist here.
Yes, you're right. The recording will still be saved and you will receive a warning written to your debug log. You can transcribe entire calls up to 4 hours long using a couple of add-ons that are available in the Twilio add-on marketplace.
There are a number of ways to record a call.
<Record> in TwiML
<Dial record> in TwiML
<Conference record> in TwiML
Record=true in Outbound REST API
Enabling recording on elastic SIP Trunk in Console
If you are looking to record a whole call, then setting Record=true when creating a call.
If you are doing this for an incoming call, then you can't record the entire call, but that's where setting record on <Dial> or <Conference> or using the <Record> element comes into play. <Dial> or <Conference> likely include an agent, so <Record> is still what you're looking for here.
Let me know if that helps at all.

Resources