Thursday, September 1, 2011

Adding answers to IVR Response Group workflow via Powershell


Introduction

in Lync 2010 you can use the web interface to create Interactive Response Groups with up to four possible answers and up to two levels of nested questions. Should you want to add a fifth question to the IVR workflow you will have to revert to using Powershell commands. Although you can create workflows from scratch using Powershell (great article to be found here:

http://blogs.technet.com/b/csps/archive/2010/09/15/rgscreateresponsegroup.aspx) you can also edit existing workflows instead of creating them completely new. In this post I will show you how to get hold of an existing workflow using Powershell, add another possible answer to a question and then save the workflow to commit the changes.

Editing an existing Lync IVR Workflow using Powershell

First you will need to get hold of the workflow objects so you can add new answers to them. First we will retrieve the workflow by its name. Then get hold of an existing queue by its name. This queue can have been created in the control panel. Finally we'll get hold of the first question of the workflow to which we plan to add a fifth option.

$Workflow = Get-CSRgsWorkflow -Name "MyWorkflowName"
$Queue = Get-CsRgsQueue -Name "MyQueue"
$Question = $workflow.DefaultAction.Question


The next step is to create another action and answer and add them to the question bank. First we create an action which will transfer the call to a queue and specify the previously referenced queue. Then we create a fifth option for the question with dtmf tone 5 and the spoken version of "Option5". Then we add the answer to the question list.
$Action5 = New-CsRgsCallAction
                   -Action TransferToQueue
                   -QueueID $Queue.Identity
$Answer5 = New-CsRgsAnswer
                   -Action $Action5
                   -DtmfResponse 5
                   -VoiceResponseList "Option5"

$Question.AnswerList.Add($Answer5)


Finally you need to save the workflow back again using the Set-CsRgsWorkflow Command

Set-CsRgsWorkflow -Instance $Workflow

That's it! You've created and added a fifth possible answer to an IVR Workflow which previously only had four possible answers. Please note, that from now on you will not be able to edit the workflow using the web interface and will get an unsupported error message instead.

2 comments:

CV said...

This is an excellent step by step guide...Much appreciated! Would you be able to provide steps for how to import a new menu greeting recording to an existing IVR response group? (i.e. If the menu was recorded as "press 1 for person1, 2 for person 2", etc... and you had another option like this article explains, how do you import a new audio file for the menu using PowerShell commands only?)

13linded said...

How would you modify an existing Answer and Action for a workflow? Is there a way to list the current answers and actions information for a workflow?

Thank you for the help!