Generally when I do direct call via <Dial><Number> Twiml, I used to listen the ringing and network message if the caller is busy or not answering or switched off. Maybe that's because I had used answerOnBridge=true?
Now I am starting a call from web client, putting myself in a conference, then creates a REST call to the caller. At that time, I only get to listen the wait music of the conference since I am alone in the conference. Nothing happens when the caller doesn't pickup or hang up without answering, it just keeps playing the music. I am using REST call with url to link the conference but that only happens when the user picks up.
return client.calls
.create({
from: from,
to: to,
url: callbackUrl,
statusCallback: 'https://xx.m.pipedream.net/',
statusCallbackEvent: ['initiated',
'ringing', 'answered',
'completed']
});
I know I can use the statusCallback to get the status and broadcast a message probably, but is there any other way to make this feel more natural and get the real network message that we usually get when we call via cellphone? Thanks!
Note: I have intention to add or transfer to users, so I need to use conference.
Don't use the /Call resource, use the conference participants end-point (Create A Participant) to be able to listen to the call progress tones (earlyMedia).
Related
We have a use case where we need the device client, connected within the browser, to be able to trigger different Say verbs at any given time during the live call between the device client and the caller. Whatever is said needs to be heard for both client and caller and included in the recording.
I set up an API endpoint that takes the CallSid and updates twiml, however, the statement is only heard for the device client and the calls are immediately disconnected. From my understanding, this is intended due to how TwiML works, since there is no other command after Say, so it believes the call is complete.
return await client.calls(callId)
.update({ twiml: '<Response><Say>Ahoy there!</Say></Response>' });
I've considered using a Redirect which would put the caller into a new flow to hear the prompt, however, the device client then wouldn't hear it, and it wouldn't be part of the recording, so that will not work. Using a conference call, the statement is only played for the new call either before they join or after their call ends.
Is there any way to accomplish this?
Is there any way to change what events trigger the status callback? Normally you can use statusCallbackEvent but I can't seem to find a way to make this work for the Voice SDK's leg of the call. It works fine on the call leg of the outbound participant, but not the Voice SDK's call leg. I only get completed status event for this leg (and I also can get ringing from the called action url).
Things I tried without success:
Updating the call using the REST api to set statusCallbackEvent to initiated ringing answered completed when the outbound call starts
Setting statusCallbackEvent as an outbound parameter on the Voice SDK's token (in PHP you can set custom parameters using $clientToken->allowClientOutgoing(...) but it seems normal parameters cannot be modified)
I really wish you could set this on the TwiML Application so that any numbers calling out with that application set will just automatically use your set events. That or let me set the parameters on the client's token.
One way to fix this is just to poll for the information but that is an ugly hack and isn't real time.
Twilio developer evangelist here.
I don't think you can do what you're asking for here, but for good reason.
When you are placing the call from the Voice SDK, that call leg is then between the application and Twilio. You know the call was "initiated", because you started it. There is no "ringing" because Twilio is not a phone and won't ring. You know it is "answered" because a request is made to your voice URL defined by the TwiML app. And finally, you do get the "completed" event.
As you say, you do get the events for the outbound leg of the call from Twilio to another phone number.
I would like to initiate an outgoing call from twilio to a number provided by a service like nexmo and be able to listen to the response.
Based on the voice message back from the receiver, i would like to determine my response
I have gone through the documentation, and from what i can make out, the outgoing call does not give me an access to the incoming stream. The Call object allows me to control the call, but not based on the voice response
client.calls
.create({
url: 'http://demo.twilio.com/docs/voice.xml',
to: '+15558675310',
from: '+15017122661'
})
.then(call => console.log(call.sid));
The call object does not provide me a way to access the conversation audio.
Overall, I would like the call to be initiated and my caller program to get access to the response voice messages that it can parse and then determine the next response.
Should i consider SIP for this scenario, since the destination number will also be having a SIP endpoint?
I was able to achieve this with the standard Twiml
The Gather verb of twilio will wait to receive voice packet and then perform speech recognition on it and send back the text.
In response to this callback, i am sending back the next audio to play and immediately followed by the next Gather.
My Twilio server has 3 pages
/listener
Sets up a <dial> and <Conference statusCallback="/gather" statusCallbackEvent="speaker start"> and appends caller to said conference. In the conference, the events request should be sent on any user speaking and conference starting (starting is just used for debugging in case it's something wrong with speaking alone, but the starting request won't be sent as well).
/gather
Uses gather to listen to speech with action='/parse'
/parse
Parses the message.
Right now, when I set the webhook to /gather, I could see 2 POST requests to /gather and /parse no problem. But when I set it to /listener, only 1 POST request per call would appear and no subsequent requests would be sent on conference start or people speaking. Can anyone possibly tell me any example of statusCallbackEvent working with gather or provide any workarounds?
Twilio developer evangelist here.
It looks to me like you are trying to use speech detection on the ongoing conference call via events?
If that is the case, then I'm afraid that is not what statusCallbacks in <Conference> do. statusCallback events during calls are asynchronous callbacks, your response to them will not affect the ongoing call. Responding to a statusCallback event with TwiML will have no effect.
Subsequently, it's not possible to simultaneously continue a <Conference> and use <Gather> on the participants.
Suppose for an incoming call to a Twilio Number '+18XXXXXXXXXX' the call is forwarded to a client with name 'CLIENT'. Now there are two legs with Callsids 'CSid1' and 'CSid2'.
If the 'CLIENT' wants to hold the call, the Connection leg with Callsid 'CSid1' is redirected to a Music url. If the 'CLIENT' resumes the call, the call 'CSid1' is again redirected to the 'CLIENT' with new CallSid 'CSid3'.
Now, how to get the single recording url for the whole Incoming call (connection with CallSid 'CSid1').
Note: The recording url for connection with callsid 'CSid2' and 'CSid3' can be obtained by setting record verb in dial tag (Two recording urls).
Any other suggestions to achieve Incoming Call recording in Twilio with hold option is also welcome.
Twilio developer evangelist here.
If you want to record the whole call in one recording, including holds, then you may want to investigate using a <Conference>.
Once your original caller dials in, put them into a <Conference>, using <Dial> with the record attribute set. At the same time, use the REST API to make a phone call to the client which also lands them in the conference.
You can then use the Participants resource to hold and unhold the caller.
This would not redirect the caller, therefore giving you one recording URL.
Let me know if this helps.