Legacy Dev Forum Posts

 View Only

Sign Up

  • 1.  Upload prompt audio

    Posted 06-05-2025 18:19

    TommyBraes | 2021-05-07 14:37:45 UTC | #1

    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 = '<source id="recording" src="'+audioURL+'" type="audio/wav" />'; } } 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


    TommyBraes | 2021-05-07 18:16:43 UTC | #2

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


    system | 2021-06-07 18:16:43 UTC | #3

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


    This post was migrated from the old Developer Forum.

    ref: 10851