Cisco Support Community
cancel
Showing results for 
Search instead for 
Did you mean: 
New Member

Scipt issue with Recording message and attaching to email

We have a script that we are trying to implement that will prompt the caller to leave a message and then attach and email out.  I have added the Goto on exception for if the caller hangs up after leaving the message and this works fine.  The problem I am having is if the caller hangs up during the prompt and doesn't even leave a message.  The script will still send the email out with an attachment of 236 Bytes but there is no content.  Is there a method Ithat can be used to verify that a message has actually been recorded?  Please see the snippet of the script:

Thanks,

Joe

3 REPLIES

Re: Scipt issue with Recording message and attaching to email

There are two scenarios you could see with this:

1. If the caller does in fact hangup during the prompt playback, the document will remain unchanged.  I.e., If the value of the document is initially DOC[], it will remain as DOC[] after the ContactInactiveException is triggered.  Therefore, a simple If step could work:

If (recording == DOC[])

  True

    /* Trash it and don't send an email */

  False

    /* Keep it and send an email */

2.  However, if the caller hangs up after the prompt has played but before recording any audio, there will be a document created and you will get a tiny wav file.  You will need to decide what you threshold is for "too small" and discard those recordings.

Here's how you do that.  The document will hold the path to the recording like so:

FILE[/opt/cisco/uccx/temp/1372869208684@15ea73.wav]

Then you need to get the length of the document in bytes, by storing that value in a variable of type Long:

Set recording_length = recording.getContentLength()

And last, apply your business logic for discarding messages which are too short to be valid (this is in bytes):

If (recording_length <= recording_min_length)

  True

    /* Trash it and don't send an email */

  False

    /* Keep it and send an email */

The Content Length of DOC[] is 0, so technically, you could have this one If statement handle both cases described above.

There you go, that should do it.  Let me know if you have questions about this solution.

Anthony Holloway

Please use the star ratings to help drive great content to the top of searches.

Anthony Holloway

Please use the star ratings to help drive great content to the top of searches.
New Member

Re: Scipt issue with Recording message and attaching to email

I found a post (https://supportforums.cisco.com/docs/DOC-24150#promptlength) that uses the following:

"

myPrompt - type Prompt, initial value P[] which is the default - this is the Prompt you just downloaded or recorded;

promptLength - type float, initial value 0.0F (default) - this will be the prompt's length.


For this demostration's sake, pretend, the myPrompt has already got its value - I am going to use a prompt that is in the prompt repository, named busy.wav (it's just a regular G.711 uLaw wave file)


For the calculation, use a Set step, where the return variable will be promptLength and the value will be this piece of code:


{

try {

Document doc = (Document) myPrompt;

javax.sound.sampled.AudioInputStream ais = javax.sound.sampled.AudioSystem.getAudioInputStream(doc.getInputStream());

int avail = ais.available();

return  avail / 8000f;

} catch (Exception e) {

return -1;

}

}

"

This is working as expected.  Is this something I should put in production or would your solution work better?

I also have a question about the file itself, is it removed from the server after the script runs?

Thanks,

Joe

Re: Scipt issue with Recording message and attaching to email

There's never a single solution to a problem.  I think you would be fine using either one.

The files are stored locally and are temporary.  In my experience they do live outside of the active call, however, I would process the audio file immediately to avoid losing it.

Anthony Holloway

Please use the star ratings to help drive great content to the top of searches.

Anthony Holloway

Please use the star ratings to help drive great content to the top of searches.
260
Views
5
Helpful
3
Replies
CreatePlease to create content