Updating RGS Workflow settings using PowerShell

I was presented with the challenge today of updating the recorded after-hours message of many Lync Response Group workflows through PowerShell.

The process wasn’t well documented anywhere, so I thought I’d publish our end solution.

  1. First off, you’ll want to capture the Identity of your workflow. This commandlet should help you fish it out of the mire:
    get-CsRgsWorkflow | ft Identity,Name -auto
  2. It would be wise now to capture the current config of the Workflow to a file:
    get-CsRgsWorkflow service:ApplicationServer:<ApplicationIdentity> > <filename>
    get-CsRgsWorkflow service:ApplicationServer:lyncfe.contoso.local/c416d398-1234-1234-1234 > C:\MyWorkflow.txt
  3. We have a suitably-formatted audio file ready to import, so let’s load it into a variable as a new CsRgsAudioFile:
    $audioFile = Import-CsRgsAudioFile -Identity "service:ApplicationServer:lyncfe.contoso.local" -FileName "NewNightMessage.wav" -Content (Get-Content C:\NewNightMessage.wav -Encoding byte -ReadCount 0)
  4. Now we create a new CsRgsPrompt that links to the file. (Here is where we would add the message text if we were instead going to use TTS)
    $prompt = New-CsRgsPrompt -AudioFilePrompt $audioFile -TextToSpeechPrompt ""

    (As I document in this post, I’ve encountered several instances where an RGS will hang up on you if you use an audio file prompt and don’t also specify an empty string as a TTS prompt).

  5. Create a new CsRgsCallAction that is the "Action" the workflow will take when we’re closed. In this case our two-step Action will be to play a prompt and then transfer the call to voicemail:
    $action = New-CsRgsCallAction –prompt $prompt -Action TransferToVoicemailUri -Uri "sip:voicemailuser@contoso.com"
  6. Read the workflow into a variable:
    $workflow = get-csRgsWorkflow “service:ApplicationServer:lyncfe.contoso.local/c416d398-1234-1234-1234”
  7. This step sets the action as the one that will take place when we’re closed, i.e. our NonBusinessHours:
    $workflow.NonBusinessHoursAction = $action
  8. And finally we write the modified workflow back in over the existing one:
    Set-CsRgsWorkflow $workflow

It seems quite intricate, but hopefully it makes sense laid out like this. The trick is remembering that we can’t retain any aspects of the previous "NonBusinessHoursAction", as they’re completely over-written when we add the new one in Step 7. Thus, whilst we only wanted to update the recorded message, we also had to ‘replace’ (or re-state) the call forward component too.

Further Reading

And of course if you’re really lucky Andrew’s new “Call Flow Manager” RGS GUI app will make the whole process redundant anyway.

Revision History

28th July 2015: This is the initial post.
2nd September 2017: Added reference and link to my post re RGS hanging up if the RgsPrompt doesn’t contain a TTS greeting.
 

– G.

3 Comments

  1. Hi Greig,

    How do you update/change the holiday of a work flow. Example a new 2017 holiday set is created for this year, how would i assign this to all the work flow and replace the current one that has been assigned.

Leave a Reply

Your email address will not be published.

... and please just confirm for me that you're not a bot first: Time limit is exhausted. Please reload the CAPTCHA.

This site uses Akismet to reduce spam. Learn how your comment data is processed.