In ongoing call with caller on flex, we are trying to play our customized message in form of audio on caller end. How can we send audio to caller end?
When incoming call lands on twilio studio our fork streaming starts through studio widget and then call goes to flex via send call to flex widget, we are receiving both inbound and outbound audio in websocket connection and sending our customised audio back to caller using this json body
const mediaMessage = {
type: 'media',
streamSid:msg.media.streamSid,
media: {
payload: base64EncodedAudio,
}
};
ws.send(JSON.stringify(mediaMessage));
Reference of this body: https://www.twilio.com/docs/voice/twiml/stream#message-media-to-twilio