Submitted by Frédéric Dubut, Microsoft

 

Introduction

 

As with all the other Lync Server components, the Response Group application can be fully managed using the Lync Server Management Shell, which contains a comprehensive set of Windows PowerShell cmdlets covering all aspects of Response Group administration. In order to help you get a quick overview of how these various cmdlets work together, this article introduces two samples to create your first response group using Windows PowerShell: one for the hunt group case and one for the interactive voice response (IVR) case.

 

Your First Hunt Group: Contoso Reception

 

One of the main scenarios enabled by hunt groups in the Response Group application is the receptionist scenario. The sample below shows how to build a very simple main line number covered by two receptionists. This sample uses some of the new features of the Response Group application in Lync Server 2010:

 

·         Attendant routing, in order to route all the calls to the agents regardless of their presence.

·         Agent anonymity, in order to hide the agent’s identity to the caller.

 

For a complete version of this script that you can copy and paste into your script editor, see Create a Response Group with a Hunt Group.

 

The first step in creating your main line is to create an agent group. This is the object that lists the agents and defines the routing method (the order in which the agents are alerted).

One thing to notice is a pattern that is common to all the objects in the Response Group application: the objects are tied to a given service instance and cannot be shared across instances. That is why the script starts by storing the Service ID we want to target in a variable, which will be reused several times.

$ServiceId = "service:ApplicationServer:rtc.contoso.com"

 

$Group = New-CsRgsAgentGroup `

             -Parent $ServiceId `

             -Name "Contoso Reception" `

             -AgentAlertTime 20 `

             -ParticipationPolicy Informal `

             -RoutingMethod Attendant `

             -AgentsByUri("sip:mindy@contoso.com", `

                          "sip:bob@contoso.com")

 

After creating the agent group, the second step is to create a queue. This is the object that contains the group(s) in order and determines what happens to the call after it has been queued for too long.

 

$PromptTO = New-CsRgsPrompt `

                -TextToSpeechPrompt "Sorry, all our agents are busy. `

                    Please call back later. Thank you."

$ActionTO = New-CsRgsCallAction `

                -Prompt $PromptTO `

                -Action Terminate

$PromptOF = New-CsRgsPrompt `

                 -TextToSpeechPrompt "Sorry, there are too many calls `

                     waiting. Please call back later. Thank you."

$ActionOF = New-CsRgsCallAction `

                 -Prompt $PromptOF `

                 -Action Terminate

 

$Queue = New-CsRgsQueue  `

             -Parent $ServiceId  `

             -Name "Contoso Reception" `

             -TimeoutThreshold 300 `

             -TimeoutAction $ActionTO `

             -OverflowThreshold 5 `

             -OverflowCandidate NewestCall `

             -OverflowAction $ActionOF `

             -AgentGroupIDList($Group.Identity)

 

Finally, the last step is to create a workflow. This is the entry point to the response group, most notably the point where you assign a SIP URI and a telephone number.

 

In order to define what action to take when a call reaches the response group, we introduce the concept of call action. This action is composed of a welcome message to be played and of the actual action. In the hunt group case, this default action is to send the call to the queue we just created.

 

$PromptWM = New-CsRgsPrompt `

                 -TextToSpeechPrompt "Welcome to Contoso. `

                     Please wait for an available agent to answer."

$ActionWM = New-CsRgsCallAction `

                 -Prompt $PromptWM `

                 -Action TransferToQueue `

                 -QueueID $Queue.Identity

 

$Workflow = New-CsRgsWorkflow `

                -Parent $ServiceId `

                -Name "Contoso Reception" `

                -Description "The Contoso Reception line." `

                -PrimaryUri "sip:reception@contoso.com" `

                -LineUri "tel:+14255551234" `

                -DisplayNumber "+1 (425) 555-1234" `

                -Active $true `

                -Anonymous $true `

                -DefaultAction $ActionWM

 

After executing this last command, the response group is immediately created along with its contact object. The service will then pick up the changes within two minutes.

 

Your First IVR: Contoso Helpdesk

 

Another interesting scenario enabled by the Response Group application is the small helpdesk scenario. In this case, instead of sending the call directly to a predefined queue, an IVR presents several options to the caller and the call is directed based on the caller input.

 

For a complete version of this script that you can copy and paste into your script editor, see Create a Response Group with an IVR.

 

The sample below shows how to build a simple helpdesk IVR, leading to two queues, each covered by two agents. The script for creating an IVR starts exactly like the script for creating a hunt group, with agent groups and queues:

 

$ServiceId = "service:ApplicationServer:rtc.contoso.com"

 

$Group_Sales = New-CsRgsAgentGroup `

                   -Parent $ServiceId `

                   -Name "Contoso Sales" `

                   -AgentAlertTime 20 `

                   -ParticipationPolicy Informal `

                   -RoutingMethod LongestIdle `

                   -AgentsByUri("sip:franz@contoso.com", `

                                "sip:marco@contoso.com")

 

$Group_Support = New-CsRgsAgentGroup `

                   -Parent $ServiceId `

                   -Name "Contoso Support" `

                   -AgentAlertTime 20 `

                   -ParticipationPolicy Informal `

                   -RoutingMethod LongestIdle `

                   -AgentsByUri("sip:david@contoso.com", `

                                "sip:john@contoso.com")

 

$Queue_Sales = New-CsRgsQueue `

                   -Parent $ServiceId `

                   -Name "Contoso Sales" `

                   -AgentGroupIDList($Group_Sales.Identity)

 

$Queue_Support = New-CsRgsQueue `

                      -Parent $ServiceId `

                      -Name "Contoso Support" `

                      -AgentGroupIDList($Group_Support.Identity)

 

Then, instead of immediately creating the workflow object, we first have to build the IVR tree with the initial question and its two answers (leading to the two queues). This sample creates the IVR from bottom to top in order to avoid nesting commands, but you could also create it from top to bottom by using parentheses.

 

$PromptA1 = New-CsRgsPrompt `

                 -TextToSpeechPrompt "Please wait while we're connecting `

                     you with the Contoso Sales department."

$ActionA1 = New-CsRgsCallAction `

                 -Prompt $PromptA1 `

                 -Action TransferToQueue `

                 -QueueID $Queue_Sales.Identity

$Answer1 = New-CsRgsAnswer `

               -Action $ActionA1 `

               -DtmfResponse 1

 

$PromptA2 = New-CsRgsPrompt `

                 -TextToSpeechPrompt "Please wait while we're connecting `

                     you with the Contoso Support department."

$ActionA2 = New-CsRgsCallAction `

                 -Prompt $PromptA2 `

                 -Action TransferToQueue `

                 -QueueID $Queue_Support.Identity

$Answer2 = New-CsRgsAnswer `

               -Action $ActionA2 `

               -DtmfResponse 2

 

$PromptQ = New-CsRgsPrompt `

               -TextToSpeechPrompt "Thank you for calling Contoso. `

                   To speak with a Sales representative, press 1. `

                   To be connected with our Support line, press 2."

$Question = New-CsRgsQuestion `

                -Prompt $PromptQ `

                -AnswerList ($Answer1, $Answer2)

 

Then, exactly as in the hunt group case, the last step is to create the actual workflow. The only difference is that the default action is now to send the call to the question we created rather than sending it directly to a predefined queue.

 

$ActionWM = New-CsRgsCallAction `

                -Action TransferToQuestion `

                -Question $Question

 

$Workflow = New-CsRgsWorkflow `

               -Parent $ServiceId `

               -Name "Contoso Helpdesk" `

               -Description "The Contoso Helpdesk line." `

               -PrimaryUri "sip:helpdesk@contoso.com" `

               -LineUri "tel:+14255554321" `

               -DisplayNumber "+1 (425) 555-4321" `

               -Active $true `

               -Anonymous $true `

               -DefaultAction $ActionWM