Upload prompt audio

Hi,

I'm trying to overwrite an existing userprompt. I based myself on the suggestion made in this topic: https://developer.mypurecloud.com/forum/t/record-and-activate-the-ivr-prompt

I'm just using vanilla JS where I:

  1. login using implicit grant
  2. get the accesstoken (to add in my POST header to upload the prompt)
  3. get the uploadUri from the prompt resource

I'm recording the prompt in my app using:

device = navigator.mediaDevices.getUserMedia({audio:true});
device.then(stream => {
recorder = new MediaRecorder(stream);
recorder.ondataavailable = e => {
chunks.push(e.data);
if (recorder.state == 'inactive'){
blob = new Blob(chunks, { type: 'audio/wav' });
audioURL = URL.createObjectURL(blob);
document.getElementById('audio').innerHTML = '';
}
}
recorder.start(1000);
});

My POST method for updating the prompt returns a 200 OK, but the prompt is not updated. Waht am I missing?

My method to upload the prompt:

let formData = new FormData();
let req = new XMLHttpRequest();
formData.append('file', blob);
req.open("POST", uploadUri);
req.setRequestHeader('Authorization', 'bearer '+ accesstoken);
req.send(formData);

Is the formData.append('file',blob); correct?

thx,

T

Nevermind. The default MediaRecorder implementation records in webm format. I used another implementation that records .wav and now it works fine.

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.