Right on Twilios website it claims: using Twilio Client’s two-way audio pipe: soundboards, audio recorders, in-game chat, and much more.-
https://www.twilio.com/help/faq/twilio-client/what-can-i-build-with-twilio-client
However I cannot find in their documentation how to go about playing a sound during a live call. Does anyone know how to go about playing a sound file during a live call?
To play arbitrary sounds during live call for fun or profit I would either use modifying live call by posting to call url or have a bit more flexibility with Conference. I'll describe it for the call option (it is less flexible as it allows only up to 2 participants).
Make a call by POST https://api.twilio.com/2010-04-01/Accounts/{AccountSid}/Calls
Remember the CallSid - either from the call POST request or subsequent callbacks to your Voice callback url
Have a publicly available url that returns TwiML which can be used to play the sounds you want.
Modify call by POST /2010-04-01/Accounts/{AccountSid}/Calls/{CallSid} You can force the ongoing call to request new TwiML from the previous url. The returned TwiML can be used to hang up a call, play some audio files (as described by #philnash) etc.
Twilio developer evangelist here.
You can play sound files during live calls using the <Play> verb in TwiML.
For example, here's how to play a cowbell 10 times:
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Play loop="10">https://api.twilio.com/cowbell.mp3</Play>
</Response>
Let me know if that helps at all.
Related
I'm placing a call from my React Native application using Twilio and the outbound call works fine. Now I want to create something that will detect when I am put on hold by the receiver. The idea here is to make my app hold for me and get back to the caller once the hold has ended.
I searched the twilio docs and services but could not find any thing regarding this use case. How would I go about doing this?
Twilio developer evangelist here.
Unfortunately, there is no mechanism to make this happen, even if there were something in the SIP signaling from the carrier, such as a re-INVITE.
In the world of SIP, putting a call on hold often involves sending a re-INVITE with different media parameters, such as saying a=sendonly in the session description. Even if this were passed end-to-end through the PSTN to Twilio, we do not generate webhooks to inform the customer’s app of this fact.
There are some good SO questions about placing a Twilio call on hold and retrieving it later--the Enqueue verb might be helpful.
I want to write a program that writes the music name to a social network status. When changing a track in Spotify, I can get the name of the music, but I don't know how to get a notification when changing music.
How do I get a callback when changing a track in Spotify's API?
You might be able to use the Web Playback SDK with player-state-changed to get these events, but this will depend on what you are going to write your programme in but it might help to look at this and see if it does what you need
I am having problem in transferring the live call. What I have to achieve is, Agent can transfer live call to IVR where IVR ask for rating "Please rate this call from 1-5" and then saves the rating via rest API.
Here is the first IVR where call is sent to flex
Here is the second IVR where flex agent should send the call
I know about Assignment Callback to redirect call to new Twiml document like
{
"instruction": "redirect",
"call_sid": "CA123456789",
"url": "http://example.com/assignment_redirect",
}
How can I use this to redirect Call to Twilio studio again, In studio all are widgets.
This is only semi-possible right now.
Studio Flow executions are a bit different from normal webhooks that return TwiML, since they MUST be the first webhook hit by the call. (For voice calls, it is also a best practice to make sure the same Studio Webhook is configured as the secondary handler and call status handler for the phone number in question, which suggests that Studio is a bit more robust in how it operates than a typical TwiML App.)
The workaround is to use the <Dial> verb to create a new call to the Studio Flow that you wish to redirect to. This assumes that each Flow that handles incoming voice has its own phone number(s).
That said, I have been told that a feature request is underway for sometime in 2021 that would allow for different flows to be linked together, so this may change in the future.
I am not exactly sure how you specify a webhook for once the Flex agent is finished with the call -- it looks like you have already done some research into the TaskRouter functionality that enables this. But assuming you can specify a webhook URL (assignment_redirect in your example), all you should need to do is create a TwiML Bin containing your <Dial> verb to the satisfaction survey Studio flow you want to receive the call, and use that TwiML bin as the webhook URL.
Using actions-on-google, when handling an intent and then using conv.ask() to send a response to the agent, is it possible to wait until the request has been successfully sent and then continue doing something else? Is there a way to await the response of the ask method?
My idea is to tell the agent to say something, manually time playing a sound (mp3) after the ask method has been successfully sent to the agent. Right now it takes a bit of time for the agent to receive the request, say the thing and then play the sound. The request gets sent, but not received instantly so the sound that I am playing plays way before the agent has said something.
Is that something possible?
Update
Right now I'm using SSML to make two different voices speak in one intent. The idea of it is that we have two "personalities" talking, and each personality has a different voice. Currently, in SSML using some attributes to do that. Let's call them P1 and P2. P1 starts by saying something, and as soon as it ends a sound of a blender gets played. Right after the sound is playing the second personality P2 starts talking, and then P1 then "replies" to it, but that all happens in one intent response. That's the idea I'm trying to implement.
If you want to play audio immediately after saying something, it more sounds like you want to use a Media response as part of what you're sending back. Your mp3 file must be available at an HTTPS address, although that address can be anything you want as long as the device can resolve it. Since it will be on the same server the webhook is running on, and the webhook has to have a public HTTPS URL, then presumably the audio will (or can) as well.
If your interest is in knowing that latency, you can probably time the difference between when you send the response and when the device requests the mp3 file.
There is no direct way to know when the Assistant has finished saying the text, but you can use tricks with the Media response to get some idea depending on your needs.
Update based on your use case.
If you're doing it all as one response, and it fits in that response, and your audio is just a few seconds long, then you can do it using SSML as a single response. That part seems fine.
If the audio is longer or you want more of a back and forth between your personalities, then you can use the Media response to play the audio (even a very short empty audio). At the end of the audio playing, it sends an event to the Action and you can then continue to the next step in your personalities responding.
I am using Twilio voice call
and
want to get the voice data of other person(in voice call) at REAL TIME. So that i can convert it into text etc.
Please let me know how to achieve this.
I know twilio has a record call feature but
1) It gives url at the end of call not at real time
2) i think it will record the whole conversation (of both persons)
I am thinking of using node.js but not able to find solutions.
Twilio developer evangelist here.
I'm afraid our programmable voice feature doesn't support streaming the audio in real time in any way other than between the callers.
You can, however, use SIP with Twilio. You would need to provide your own PBX to make this work, but it then gives you access to the streaming audio, which you can then work with yourself.
Let me know if this helps at all?