Create a Call queue via cmdlets
Prerequisites
Install PowerShell on your computer.
Set up your computer for Windows PowerShell
MSTeams Module Installed
Install-Module -Name MicrosoftTeams -Force -AllowClobber
Microsoft Graph module installed
Install-Module -Name Microsoft.Graph -Force -AllowClobber
Ensure you have tenant administration rights.
Purchase Microsoft Teams Phone.
The agents, distribution lists, and Teams channels mentioned in this article have already been created.
Note
The Teams Channel cmdlet used in this scenario is part of the Public Preview version of Teams PowerShell Module. For more information, see Install Teams PowerShell public preview and also see Microsoft Teams PowerShell Release Notes.
Users who already have the MicrosoftTeams module installed should Update-Module MicrosoftTeams
to ensure the most up-to-date version is installed.
Scenario
In this scenario, you create the following three call queues:
- Sales Call Queue
- Support Call Queue
- Facilities Collaborative Calling Queue
Sales Call Queue information:
- Nested behind Auto Attendant: Yes
- Direct calling from PSTN: No
- Language: English US
- Greeting: None
- Music on hold: Play an audio file
- Filename: sales-hold-in-queue-music.wav
- Call Answering: Users
- Bill@contoso.com
- Mary@contoso.com
- Conference Mode: On
- Routing method: Attendant
- Presence-based routing: Off
- Call agents can opt out of taking calls: Yes
- Call agent alert time: 15
- Call overflow handling: 200
- Redirect to: Adele@contoso.com
- Call timeout handling: 120 seconds
- Redirect to: Adele@contoso.com
Support Call Queue information:
- Nested behind Auto Attendant: Yes
- Direct calling from PSTN: No
- Language: English UK
- Greeting: Play an audio file
- Filename: support-greeting.wav
- Music on hold: Play an audio file
- Filename: support-hold-in-queue-music.wav
- Call Answering: Support distribution list
- Support@contoso.com
- Conference Mode: On
- Routing method: Longest Idle
- Presence-based routing: N/A – on by default because of Longest Idle
- Call agents can opt out of taking calls: No
- Call agent alert time: 15
- Call overflow handling: 200
- Redirect: Support Shared Voicemail
- Play an audio file (support-shared-voicemail-greeting.wav)
- Transcription enabled
- Redirect: Support Shared Voicemail
- Call timeout handling: 45 minutes
- Redirect: Support Shared Voicemail
- TTS: "We're sorry to have kept you waiting and are now transferring your call to voicemail."
- Transcription enabled
- Redirect: Support Shared Voicemail
Facilities Collaborative Calling Queue information:
- Nested behind Auto Attendant: No
- Direct calling from PSTN: No (internal calling only)
- Language: French FR
- Greeting: None
- Music on hold: default
- Call Answering: Team: Facilities
- Call Answering Channel: Help Desk
- Channel Owner: Fred@contoso.com
- Conference Mode: On
- Routing method: Round Robin
- Presence-based routing: On
- Call agents can opt out of taking calls: No
- Call agent alert time: 15
- Call overflow handling: 200
- Disconnect
- Call timeout handling: 45 minutes
- Disconnect
Login
When prompted, enter your Teams administrator credentials.
$credential = Get-Credential
Connect-MicrosoftTeams -Credential $credential
Connect-MgGraph -Credential $credential
Sales Queue
Create Audio Files
Replace d:\\
with the path to where the wav files are stored on your computer.
$content = [System.IO.File]::ReadAllBytes('d:\sales-hold-in-queue-music.wav')
$audioFileSalesHoldInQueueMusicID = (Import-CsOnlineAudioFile -ApplicationID HuntGroup -FileName "sales-hold-in-queue-music.wav" -Content $content).ID
Get Users ID
$userAdeleID = (Get-CsOnlineUser -Identity "sip:adele@contoso.com").Identity
$userSalesBillID = (Get-CsOnlineUser -Identity "sip:bill@contoso.com").Identity
$userSalesMaryID = (Get-CsOnlineUser -Identity "sip:mary@contoso.com").Identity
Get list of supported languages
Get-CsAutoAttendantSupportedLanguage
Create Call queue
New-CsCallQueue -Name "Sales" -AgentAlertTime 15 -AllowOptOut $true -MusicOnHoldAudioFileID $audioFileSalesHoldInQueueMusicID -OverflowAction Forward -OverflowActionTarget $userAdeleID -OverflowThreshold 200 -TimeoutAction Forward -TimeoutActionTarget $userAdeleID -TimeoutThreshold 120 -RoutingMethod Attendant -ConferenceMode $true -User @($userSalesBillID, $userSalesMaryID) -LanguageID "en-US"
Get license types
Get-MgSubscribedSku
Create and assign resource account
A phone number isn't required here as the call queue is nested behind an auto attendant.
- ApplicationID
- Auto Attendant: ce933385-9390-45d1-9512-c8d228074e07
- Call Queue: 11cd3e2e-fccb-42ad-ad00-878b93575e07
The license type shown after (PHONESYSTEM_VIRTUALUSER)
must be one that's listed by the Get-MgSubscribedSku
cmdlet.
New-CsOnlineApplicationInstance -UserPrincipalName Sales-RA@contoso.com -DisplayName "Sales" -ApplicationID "11cd3e2e-fccb-42ad-ad00-878b93575e07"
Update-MgUser -UserId "Sales-RA@contoso.com" -UsageLocation US
Set-MgUserLicense -UserId "Sales-RA@contoso.com" -AddLicenses @(contoso:PHONESYSTEM_VIRTUALUSER) -RemoveLicenses @()
$applicationInstanceID = (Get-CsOnlineUser -Identity "Sales-RA@contoso.com").Identity
$callQueueID = (Get-CsCallQueue -NameFilter "Sales").Identity
New-CsOnlineApplicationInstanceAssociation -Identities @($applicationInstanceID) -ConfigurationID $callQueueID -ConfigurationType CallQueue
Support Queue
Create audio files
Replace d:\\
with the path to where the wav files are stored on your computer.
$content1 = [System.IO.File]::ReadAllBytes('d:\support-greeting.wav')
$audioFileSupportGreetingID = (Import-CsOnlineAudioFile -ApplicationID HuntGroup -FileName "support-greeting.wav" -Content $content1).ID
$content2 = [System.IO.File]::ReadAllBytes('d:\support-hold-in-queue-music.wav')
$audioFileSupportHoldInQueueMusicID = (Import-CsOnlineAudioFile -ApplicationID HuntGroup -FileName "support-hold-in-queue-music.wav" -Content $content2).ID
$content3 = [System.IO.File]::ReadAllBytes('d:\support-shared-voicemail-greeting.wav')
$audioFileSupportSharedVoicemailGreetingID = (Import-CsOnlineAudioFile -ApplicationID HuntGroup -FileName "support-shared-voicemail-greeting.wav" -Content $content3).ID
Get Support team group ID
$teamSupportID = (Get-Team -DisplayName "Support").GroupID
Get list of supported languages
Get-CsAutoAttendantSupportedLanguage
Create Call queue
New-CsCallQueue -Name "Support" -AgentAlertTime 15 -AllowOptOut $false -DistributionLists $teamSupportID -WelcomeMusicAudioFileID $audioFileSupportGreetingID -MusicOnHoldAudioFileID $audioFileSupportHoldInQueueMusicID -OverflowAction SharedVoicemail -OverflowActionTarget $teamSupportID -OverflowThreshold 200 -OverflowSharedVoicemailAudioFilePrompt $audioFileSupportSharedVoicemailGreetingID -EnableOverflowSharedVoicemailTranscription $true -TimeoutAction SharedVoicemail -TimeoutActionTarget $teamSupportID -TimeoutThreshold 2700 -TimeoutSharedVoicemailTextToSpeechPrompt "We're sorry to have kept you waiting and are now transferring your call to voicemail." -EnableTimeoutSharedVoicemailTranscription $true -RoutingMethod LongestIdle -ConferenceMode $true -LanguageID "en-US"
Get license types
Get-MgSubscribedSku
Create and Assign Resource Account
A phone number isn't required here as the call queue is nested behind an auto attendant.
- ApplicationID
- Auto Attendant: ce933385-9390-45d1-9512-c8d228074e07
- Call Queue: 11cd3e2e-fccb-42ad-ad00-878b93575e07
The license type shown after (PHONESYSTEM_VIRTUALUSER)
must be one that's listed by the Get-MgSubscribedSku
cmdlet.
New-CsOnlineApplicationInstance -UserPrincipalName Support-RA@contoso.com -DisplayName "Support" -ApplicationID "11cd3e2e-fccb-42ad-ad00-878b93575e07"
Update-MgUser -UserId "Support-RA@contoso.com" -UsageLocation US
Set-MgUserLicense -UserId "Support-RA@contoso.com" -AddLicenses @(contoso:PHONESYSTEM_VIRTUALUSER) -RemoveLicenses @()
$applicationInstanceID = (Get-CsOnlineUser -Identity "Support-RA@contoso.com").Identity
$callQueueID = (Get-CsCallQueue -NameFilter "Support").Identity
New-CsOnlineApplicationInstanceAssociation -Identities @($applicationInstanceID) -ConfigurationID $callQueueID -ConfigurationType CallQueue
Facilities Collaborative Calling Queue
Get Facilities team group ID
$teamFacilitiesGroupID = (Get-Team -DisplayName "Facilities").GroupID
Get Facilities Help Desk team channel ID
Get-TeamChannel -GroupId $teamFacilitiesGroupID
$teamFacilitiesHelpDeskChannelID = "{assign ID from output of above command}"
Get Facilities Help Desk channel owner user ID
$teamFacilitiesHelpDeskChannelUserID = (Get-TeamChannelUser -GroupId $teamFacilitiesGroupID -DisplayName "Help Desk" -Role Owner).UserId
Get on behalf of Calling Resource Account ID
$oboResourceAccountID = (Get-CsOnlineUser -Identity "MainAA-RA@contoso.com").Identity
Get list of supported languages
Get-CsAutoAttendantSupportedLanguage
Create Call queue
New-CsCallQueue -Name "Facilities" -AgentAlertTime 15 -AllowOptOut $false -ChannelId $teamFacilitiesHelpDeskChannelID -ChannelUserObjectId $teamFacilitiesHelpDeskChannelUserID -ConferenceMode $true -DistributionList $teamFacilitiesGroupID -LanguageID "fr-FR" -OboResourceAccountIds $oboResourceAccountID -OverflowAction DisconnectWithBusy -OverflowThreshold 200 -RoutingMethod RoundRobin -TimeoutAction Disconnect -TimeoutThreshold 2700 -UseDefaultMusicOnHold $true
Get license types
Get-MgSubscribedSku
Create and assign Resource Account
A phone number isn't required here as the call queue is nested behind an auto attendant.
- ApplicationID
- Auto Attendant: ce933385-9390-45d1-9512-c8d228074e07
- Call Queue: 11cd3e2e-fccb-42ad-ad00-878b93575e07
The license type shown after (PHONESYSTEM_VIRTUALUSER)
must be one that's listed by the Get-MgSubscribedSku
cmdlet.
New-CsOnlineApplicationInstance -UserPrincipalName Facilities-RA@contoso.com -DisplayName "Facilities" -ApplicationID "11cd3e2e-fccb-42ad-ad00-878b93575e07"
Update-MgUser -UserId "Facilities-RA@contoso.com" -UsageLocation US
Set-MgUserLicense -UserId "Facilities-RA@contoso.com" -AddLicenses @(contoso:PHONESYSTEM_VIRTUALUSER) -RemoveLicenses @()
$applicationInstanceID = (Get-CsOnlineUser -Identity "Facilities-RA@contoso.com").Identity
$callQueueID = (Get-CsCallQueue -NameFilter "Facilities").Identity
New-CsOnlineApplicationInstanceAssociation -Identities @($applicationInstanceID) -ConfigurationID $callQueueID -ConfigurationType CallQueue
Related articles
Plan for Teams Auto attendants and Call queues