-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathAA_CC.ps1
More file actions
228 lines (200 loc) · 9.14 KB
/
Copy pathAA_CC.ps1
File metadata and controls
228 lines (200 loc) · 9.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
#This script will configure a Landis Contact Center queue resource account to be used as a transfer option in a MS Teams Auto Attendant.
#The admin running this script will be promted to make selections based on the desired call flow of the Auto Attendant.
#Prerequisites:
#Active connection to Skype for Business online powershell
#Teams Auto Attendant created
#Resource account created for Landis Contact Center Queue
#Author: Clayton Martin, Landis Technologies LLC
#This script is provided "As Is" without any warranty of any kind. In no event shall the author be liable for any damages arising from the use of this script.
Try {
$AAS = Get-CsAutoAttendant
$RAS = Get-CsOnlineApplicationInstance
$Objects = @("After Hours Call Flow", "Business Hours Call Flow", "Operator", "Holiday")
$Actions = @("Redirect Call", "Menu Options")
$dial_Key = @(1, 2, 3, 4, 5, 6, 7, 8, 9, 0)
$ErrorActionPreference = "Stop"
#Select AA
$global:selection = $null
Clear-Host
if (!$aas.count) {
$AA_Identity = $AAS.Identity
$AAName = $AAS.Name
Read-Host "Editing $AAName. Press ENTER to continue..."
}
if ($AAS.count) {
Do {
Write-Host 'Auto Attendant to Edit:'
for ($i = 0; $i -lt $AAS.count; $i++) {
Write-Host -ForegroundColor Cyan " $($i+1)." $AAS.Name[$i]
}
Write-Host # empty line
$global:ans = (Read-Host 'Please enter selection') -as [int]
} While ((-not $ans) -or (0 -gt $ans) -or ($AAS.Count -lt $ans))
$global:selection = $AAS[$ans - 1]
$AA_Identity = $global:selection.Identity
}
#Select Resource Account
$global:selection = $null
Clear-Host
if (!$ras.count) {
$RA_ObjectID = $RAS.ObjectId
$RAName = $RAS.DisplayName
Read-Host "Editing $RAName. Press ENTER to continue..."
}
if ($RAS.count) {
Do {
Write-Host 'Resource Account to transfer to:'
for ($i = 0; $i -lt $RAS.count; $i++) {
Write-Host -ForegroundColor Cyan " $($i+1)." $RAS.DisplayName[$i]
}
Write-Host # empty line
$global:ans = (Read-Host 'Please enter selection') -as [int]
} While ((-not $ans) -or (0 -gt $ans) -or ($RAS.Count -lt $ans))
$global:selection = $RAS[$ans - 1]
$RA_ObjectID = $global:selection.ObjectId
}
#Select Object
$global:selection = $null
Clear-Host
Do {
Write-Host 'Auto Attendant Object to Edit:'
for ($i = 0; $i -lt $Objects.count; $i++) {
Write-Host -ForegroundColor Cyan " $($i+1)." $Objects[$i]
}
Write-Host # empty line
$global:ans = (Read-Host 'Please enter selection') -as [int]
} While ((-not $ans) -or (0 -gt $ans) -or ($Objects.Count -lt $ans))
$global:selection = $Objects[$ans - 1]
$Object = $global:selection
#Select Actions
Function Get-AAAction {
$global:selection = $null
Clear-Host
Do {
Write-Host 'Auto Attendant Action:'
for ($i = 0; $i -lt $Actions.count; $i++) {
Write-Host -ForegroundColor Cyan " $($i+1)." $Actions[$i]
}
Write-Host # empty line
$global:ans = (Read-Host 'Please enter selection') -as [int]
} While ((-not $ans) -or (0 -gt $ans) -or ($Actions.Count -lt $ans))
$global:selection = $Actions[$ans - 1]
return $global:selection
}
#Select Key
Function Get-AAKey {
$global:selection = $null
Clear-Host
Do {
Write-Host 'Auto Attendant Dial Key to transfer to Resource Account:'
for ($i = 0; $i -lt $dial_Key.count; $i++) {
Write-Host -ForegroundColor Cyan " $($i+1)." $dial_Key[$i]
}
Write-Host # empty line
$global:ans = (Read-Host 'Please enter selection') -as [int]
} While ((-not $ans) -or (0 -gt $ans) -or ($dial_Key.Count -lt $ans))
$global:selection = $dial_Key[$ans - 1]
return "Tone" + $global:selection
}
$aa = Get-CsAutoAttendant -Identity $AA_Identity
If ($Object -like "Holiday") {
$HCF = $AA.CallFlows | where { $_.Menu.Name -like "Holiday call flow" }
#Select Holiday
$global:selection = $null
Clear-Host
Do {
Write-Host 'Holiday to Edit:'
for ($i = 0; $i -lt $HCF.count; $i++) {
Write-Host -ForegroundColor Cyan " $($i+1)." $HCF.Name[$i]
}
Write-Host # empty line
$global:ans = (Read-Host 'Please enter selection') -as [int]
} While ((-not $ans) -or (0 -gt $ans) -or ($HCF.Count -lt $ans))
$global:selection = $HCF[$ans - 1]
$HN = $global:selection.Name
$holiday = $HCF | where Name -Like $HN | select -First 1
$Callable_Entity = New-CsAutoAttendantCallableEntity -Identity $RA_ObjectID -Type ApplicationEndpoint
$holidayMO = New-CsAutoAttendantMenuOption -Action TransferCallToTarget -CallTarget $Callable_Entity -DtmfResponse Automatic
$holiday.Menu.MenuOptions = $holidayMO
}
If ($Object -like "Operator") {
$aa.Operator = New-CsAutoAttendantCallableEntity -Identity $RA_ObjectID -Type ApplicationEndpoint
}
If ($Object -like "After Hours Call Flow") {
$AHCF = $AA.CallFlows.menu | where Name -like "After hours call flow" | select -First 1
$AHCFM = $AHCF.MenuOptions | where DtmfResponse -Like "Automatic" | select -First 1
If ($AHCFM -ne $null) {
$action = Get-AAAction
if ($action -like "Redirect Call") {
$AHCFM.Action = "TransferCallToTarget"
$AHCFM.CallTarget = New-CsAutoAttendantCallableEntity -Identity $RA_ObjectID -Type ApplicationEndpoint
}
if ($action -like "Menu Options") {
$key = Get-AAKey
$AHCFM.Action = "TransferCallToTarget"
$AHCFM.DtmfResponse = $key
$AHCFM.CallTarget = New-CsAutoAttendantCallableEntity -Identity $RA_ObjectID -Type ApplicationEndpoint
$AHCF.Prompts = @(New-CsAutoAttendantPrompt -TextToSpeechPrompt "This is a default greeting. Please edit in the Teams Admin Center.")
}
}
If ($AHCFM -eq $null) {
$key = Get-AAKey
$mo = $AHCF.MenuOptions | where DtmfResponse -Like $key | select -First 1
if ($mo -ne $null) {
$mo.Action = "TransferCallToTarget"
$mo.CallTarget.Type = "ApplicationEndpoint"
$mo.CallTarget.ID = $RA_ObjectID
}
if ($mo -eq $null) {
$Callable_Entity = New-CsAutoAttendantCallableEntity -Identity $RA_ObjectID -Type ApplicationEndpoint
$menuOption = New-CsAutoAttendantMenuOption -Action TransferCallToTarget -DtmfResponse $key -CallTarget $Callable_Entity
if ($AHCF.MenuOptions -ne $null) {
$AHCF.MenuOptions.Add($menuOption)
}
if ($AHCF.MenuOptions -eq $null) {
$AHCF.MenuOptions = @($menuOption)
}
}
}
}
If ($Object -like "Business Hours Call Flow") {
$AHCF = $AA.DefaultCallFlow.menu
$AHCFM = $AHCF.MenuOptions | where DtmfResponse -Like "Automatic" | select -First 1
If ($AHCFM -ne $null) {
$action = Get-AAAction
if ($action -like "Redirect Call") {
$AHCFM.Action = "TransferCallToTarget"
$AHCFM.CallTarget = New-CsAutoAttendantCallableEntity -Identity $RA_ObjectID -Type ApplicationEndpoint
}
if ($action -like "Menu Options") {
$key = Get-AAKey
$AHCFM.Action = "TransferCallToTarget"
$AHCFM.DtmfResponse = $key
$AHCFM.CallTarget = New-CsAutoAttendantCallableEntity -Identity $RA_ObjectID -Type ApplicationEndpoint
$AHCF.Prompts = @(New-CsAutoAttendantPrompt -TextToSpeechPrompt "This is a default greeting. Please edit in the Teams Admin Center.")
}
}
If ($AHCFM -eq $null) {
$key = Get-AAKey
$mo = $AHCF.MenuOptions | where DtmfResponse -Like $key | select -First 1
if ($mo -ne $null) {
$mo.Action = "TransferCallToTarget"
$mo.CallTarget.Type = "ApplicationEndpoint"
$mo.CallTarget.ID = $RA_ObjectID
}
if ($mo -eq $null) {
$Callable_Entity = New-CsAutoAttendantCallableEntity -Identity $RA_ObjectID -Type ApplicationEndpoint
$menuOption = New-CsAutoAttendantMenuOption -Action TransferCallToTarget -DtmfResponse $key -CallTarget $Callable_Entity
if ($AHCF.MenuOptions -ne $null) {
$AHCF.MenuOptions.Add($menuOption)
}
if ($AHCF.MenuOptions -eq $null) {
$AHCF.MenuOptions = @($menuOption)
}
}
}
}
Set-CsAutoAttendant -Instance $aa
}
catch { Throw "Cannot Edit Auto Attendant. " + $error[0] }
Write-Host "Auto attendant configuration changed sucessfully!"