设置 - 通过 PowerShell 创建自动助理

警告

夏令时变更 - 手动更改某些客户所需的自动助理时区。

2026 年 11 月 1 日,北美的夏令时将结束。

在加拿大,阿尔伯塔省、不列颠哥伦比亚省和曼尼托巴省将保持夏令时,并且不会将时钟向后移动一小时。

拥有自动助理服务的客户的时区配置参考 (UTC-7:00) 山区时间 (美国 & 加拿大) 、 (UTC-8:00) 太平洋时间 (美国 & 加拿大) ,或 (UTC-05:00) 东部时间 (美国 & 加拿大) 必须更新如下:

  • 艾伯塔省:永久移动到 UTC-6:00。

    • 由于萨斯喀彻温省没有实施 DST 时间,因此将自动助理时区选择从美国 & 加拿大 (山区时间) (UTC-7:00) 更改为 萨斯喀彻温省) (UTC-6:00 。
  • 不列颠哥伦比亚省:永久移动到 UTC-7:00。

    • 由于亚利桑那州没有实施 DST 时间,因此将自动助理时区选择从美国 & 加拿大 (太平洋时间 (UTC-8:00) ) 更改为 亚利桑那州) (UTC-7:00 。
  • 曼尼托巴省:永久移动到 UTC-5:00。

    • 将自动助理时区选择从美国) &) 加拿大东部时间 ( (UTC-05:00 更改为波哥大、利马、基多、里奥布兰科或切图马尔 () UTC-05:0) 0 (UTC-05:00,因为这些地区没有实施 DST 时间。

在安大略省,以下社区和地区将不会让时钟倒流,并将全年保持中部夏令时:

  • Kenora
  • Dryden
  • 弗朗西斯堡
  • Sioux Lookout
  • Red Lake
  • Rainy River
  • 目前遵循中部时间并按季节变化时钟的 90 度子午线以西的其他社区

使用自动助理服务的这些地区的时区配置参考 (UTC-05:00) 美国东部时间 (美国 & 加拿大) 应将时区选择更改为 (UTC-05:00) 波哥大、利马、基多、里奥布兰科 或切 图马尔 (UTC-05:0) 0 ,因为这些地区没有实施 DST 时间。

最近六个月 (自动助理中的新增功能)

先决条件

  1. 在计算机上安装 PowerShell。

    • 为 Windows PowerShell 设置计算机

    • 已安装 MSTeams 模块

      Install-Module -Name MicrosoftTeams -Force -AllowClobber
      
    • 已安装 Microsoft Graph 模块

      Install-Module -Name Microsoft.Graph -Force -AllowClobber
      
  2. 确保你具有租户管理权限。

  3. 购买 Microsoft Teams 电话。

  4. 本文中提到的呼叫队列是使用 “使用 PowerShell cmdlet 创建呼叫队列 ”指南设置的。

注意

本文中提到的某些 cmdlet 可能是 Teams PowerShell 模块的公共预览版的一部分。 有关详细信息,请参阅 安装 Teams PowerShell 公共预览版 ,另请参阅 Microsoft Teams PowerShell 发行说明。

已安装 MicrosoftTeams 模块的用户应 Update-Module MicrosoftTeams 确保安装最新版本。

使用场景

构建了以下自动助理呼叫流:

显示使用 cmdlet 生成的自动助理呼叫流的屏幕截图。

有用的配置信息:

  • 自动助理:Contoso 主要

    • 操作员:Adele Vance
    • 启用语音输入:关闭
    • 目录搜索:无
    • 节假日:
      • 2022 年 1 月 1 日
      • 2022 年 12 月 24 日
      • 2022 年 12 月 25 日
  • 自动助理:Contoso 按名称拨号

    • 操作员:Adele Vance
    • 时区:UTC
    • 语言:美国英语
    • 启用语音输入:开
    • 问候语:无
    • 菜单:TTS,“请说出或输入您要联系的人的姓名。 要返回上一个菜单,请按 9”
    • 目录搜索: 按名称拨号
    • 拨号范围:销售 & 支持成员

登录

出现提示时,输入 Teams 管理员凭据。

$credential = Get-Credential
Connect-MicrosoftTeams -Credential $credential
Connect-MgGraph -Credential $credential

获取运营商信息

$operatorID = (Get-CsOnlineUser -Identity "sip:adele@contoso.com").Identity

$operatorEntity = New-CsAutoAttendantCallableEntity -Identity $operatorID -Type User

按名称拨号 自动助理 - 资源帐户创建

在此处创建资源帐户,以便可以在主自动助理上引用它。 可以稍后创建实际的“按名称拨号”自动助理。

获取许可证类型

Get-MgSubscribedSku

创建并分配资源帐户

这里不需要电话号码,因为呼叫队列嵌套在自动助理后面。

  • ApplicationID
    • 自动助理: ce933385-9390-45d1-9512-c8d228074e07
    • 呼叫队列:11cd3e2e-fccb-42ad-ad00-878b93575e07
New-CsOnlineApplicationInstance -UserPrincipalName ContosoDialByNameAA-RA@contoso.com -DisplayName "Contoso Dial By Name AA" -ApplicationID "ce933385-9390-45d1-9512-c8d228074e07"

Update-MgUser -UserId "ContosoDialByNameAA-RA@contoso.com" -UsageLocation US

Set-MgUserLicense -UserId "ContosoDialByNameAA-RA@contoso.com" -AddLicenses @(contoso:PHONESYSTEM_VIRTUALUSER) -RemoveLicenses @()

$dialByNameApplicationInstanceID = (Get-CsOnlineUser "ContosoDialByNameAA-RA@contoso.com").Identity

Contoso 主菜单自动助理

创建假日计划

$dtr = New-CsOnlineDateTimeRange -Start "24/12/2022" -End "25/12/2022"

$christmasSchedule = New-CsOnlineSchedule -Name "Christmas" -FixedSchedule -DateTimeRanges @($dtr)

$dtr = New-CsOnlineDateTimeRange -Start "01/01/2022" -End "02/01/2022"

$newyearSchedule = New-CsOnlineSchedule -Name "New Year" -FixedSchedule -DateTimeRanges @($dtr)

创建地址、传真和电子邮件信息提示

$addressPrompt = New-CsAutoAttendantPrompt -TextToSpeechPrompt "To repeat this information at any time press the * key. Our mailing address is: 123 Main Street, Any town, Any Place, County. Our email address is: info@contoso.com. Our fax number is: 929-555-0151"

创建假日提示和菜单选项

$christmasGreetingPrompt = New-CsAutoAttendantPrompt -TextToSpeechPrompt "Thank you for calling Contoso. Our offices ae currently closed for the Christmas holiday. Our Sales and Support teams will be happy to take your call on the next business day. Regular business hours are Monday through Friday from 8:30 am to 5:00 pm and Saturday from 10:00 am to 4:00 pm eastern time. Thank you for calling Contoso."

$christmasMenuOption = New-CsAutoAttendantMenuOption -Action DisconnectCall -DtmfResponse Automatic

$christmasMenu = New-CsAutoAttendantMenu -Name "Christmas Menu" -MenuOptions @($christmasMenuOption)

$christmasCallFlow = New-CsAutoAttendantCallFlow -Name "Christmas" -Greetings @($christmasGreetingPrompt) -Menu $christmasMenu

$christmasCallHandlingAssociation = New-CsAutoAttendantCallHandlingAssociation -Type Holiday -ScheduleId $christmasSchedule.Id -CallFlowId $christmasCallFlow.Id

$newyearGreetingPrompt = New-CsAutoAttendantPrompt -TextToSpeechPrompt "Thank you for calling Contoso. Our offices ae currently closed for the New Year's holiday. Our Sales and Support teams will be happy to take your call on the next business day. Regular business hours are Monday through Friday from 8:30 am to 5:00 pm and Saturday from 10:00 am to 4:00 pm eastern time. Thank you for calling Contoso."

$newyearMenuOption = New-CsAutoAttendantMenuOption -Action DisconnectCall -DtmfResponse Automatic

$newyearMenu = New-CsAutoAttendantMenu -Name "New Year Menu" -MenuOptions @($newyearMenuOption)

$newyearCallFlow = New-CsAutoAttendantCallFlow -Name "New Year" -Greetings @($newyearGreetingPrompt) -Menu $newyearMenu

$newyearCallHandlingAssociation = New-CsAutoAttendantCallHandlingAssociation -Type Holiday -ScheduleId $newyearSchedule.Id -CallFlowId $newyearCallFlow.Id

创建非工作时间计划

$timerangeMoFr = New-CsOnlineTimeRange -Start 08:30 -end 17:00

$timerangeSa = New-CsOnlineTimeRange -Start 10:00 -end 16:00

$afterHoursSchedule = New-CsOnlineSchedule -Name "After Hours Schedule" -WeeklyRecurrentSchedule -MondayHours @($timerangeMoFr) -TuesdayHours @($timerangeMoFr) -WednesdayHours @($timerangeMoFr) -ThursdayHours @($timerangeMoFr) -FridayHours @($timerangeMoFr) -SaturdayHours @($timerangeSa) -Complement

创建非工作时间提示和菜单选项

$afterHoursGreetingPrompt = New-CsAutoAttendantPrompt -TextToSpeechPrompt "Thank you for calling Contoso. Our offices are now closed. Regular business hours are Monday through Friday from 8:30 am to 5:00 pm and Saturday from 10:00 am to 4:00 pm eastern time."

$afterHoursMenuPrompt = New-CsAutoAttendantPrompt -TextToSpeechPrompt "To leave a voicemail for our sales team press 1. To leave a message for our support team press 2. If you know the name of the person you would like to reach, press 3. For our address, email and fax information press 4."

$afterHoursMenuOption1Target = (Get-Team -displayname "Sales").GroupID

$afterHoursMenuOption1Entity = New-CsAutoAttendantCallableEntity -Identity $afterHoursMenuOption1Target -Type SharedVoiceMail -EnableTranscription -EnableSharedVoicemailSystemPromptSuppression

$afterHoursMenuOption1 = New-CsAutoAttendantMenuOption -Action TransferCallToTarget -DtmfResponse Tone1 -CallTarget $afterHoursMenuOption1Entity

$afterHoursMenuOption2Target = (Get-Team -displayname "Support").GroupID

$afterHoursMenuOption2Entity = New-CsAutoAttendantCallableEntity -Identity $afterHoursMenuOption2Target -Type SharedVoicemail -EnableTranscription -EnableSharedVoicemailSystemPromptSuppression

$afterHoursMenuOption2 = New-CsAutoAttendantMenuOption -Action TransferCallToTarget -DtmfResponse Tone2 -CallTarget $afterHoursMenuOption2Entity

$dialbynameAAOption3Target = (Get-CsOnlineUser -Identity "ContosoDialByNameAA-RA@contoso.com").Identity

$dialbynameAAMenuOption3Entity = New-CsAutoAttendantCallableEntity -Identity $dialbynameAAOption3Target -Type applicationendpoint

$dialbynameAAMenuOption3 = New-CsAutoAttendantMenuOption -Action TransferCallToTarget -DtmfResponse Tone3 -CallTarget $dialbynameAAMenuOption3Entity

$afterHoursMenuOption4 = New-CsAutoAttendantMenuOption -Action Announcement -DtmfResponse Tone4 -Prompt $addressPrompt

创建非工作时间菜单和呼叫流程

$afterHoursMenu = New-CsAutoAttendantMenu -Name "After Hours Menu" -MenuOptions @($afterHoursMenuOption1, $afterHoursMenuOption2, $dialbynameAAMenuOption3, $afterHoursMenuOption4) -Prompt $afterHoursMenuPrompt

$afterHoursCallFlow = New-CsAutoAttendantCallFlow -Name "After Hours Call Flow" -Greetings @($afterHoursGreetingPrompt) -Menu $afterHoursMenu

$afterHoursCallHandlingAssociation = New-CsAutoAttendantCallHandlingAssociation -Type AfterHours -ScheduleId $afterHoursSchedule.Id -CallFlowId $afterHoursCallFlow.Id

创建营业时间提示和菜单选项

$openHoursGreetingPrompt = New-CsAutoAttendantPrompt -TextToSpeechPrompt " Thank you for calling Contoso."

$openHoursMenuPrompt = New-CsAutoAttendantPrompt -TextToSpeechPrompt "For Sales press 1. For Support press 2. If you know the name of the person you would like to reach, press 3. For our address, email and fax information, press 4. For all other inquiries press 0 to speak with the operator."

$openHoursMenuOption1Target = (Get-CsOnlineUser "Sales-RA@contoso.com").Identity

$openHoursMenuOption1Entity = New-CsAutoAttendantCallableEntity -Identity $openHoursMenuOption1Target -Type applicationendpoint

$openHoursMenuOption1 = New-CsAutoAttendantMenuOption -Action TransferCallToTarget -DtmfResponse Tone1 -CallTarget $openHoursMenuOption1Entity

$openHoursMenuOption2Target = (Get-CsOnlineUser "Support-RA@contoso.com").Identity

$openHoursMenuOption2Entity = New-CsAutoAttendantCallableEntity -Identity $openHoursMenuOption2Target -Type applicationendpoint

$openHoursMenuOption2 = New-CsAutoAttendantMenuOption -Action TransferCallToTarget -DtmfResponse Tone2 -CallTarget $openHoursMenuOption2Entity

$openHoursMenuOption4 = New-CsAutoAttendantMenuOption -Action Announcement -DtmfResponse Tone4 -Prompt $addressPrompt

$openHoursMenuOption0 = New-CsAutoAttendantMenuOption -Action TransferCallToOperator -DtmfResponse Tone0

创建营业时间菜单

$openHoursMenu = New-CsAutoAttendantMenu -Name "Open Hours Menu" -MenuOptions @($openHoursMenuOption1, $openHoursMenuOption2, $dialbynameAAMenuOption3, $openHoursMenuOption4, $openHoursMenuOption0) -Prompt $openHoursMenuPrompt

$openHoursCallFlow = New-CsAutoAttendantCallFlow -Name "Open Hours Call Flow" -Greetings @($openHoursGreetingPrompt) -Menu $openHoursMenu

创建自动助理

$autoAttendant = New-CsAutoAttendant -Name "Contoso Main" -DefaultCallFlow $openHoursCallFlow -CallFlows @($afterHoursCallFlow, $christmasCallFlow, $newyearCallFlow) -CallHandlingAssociations @($afterHoursCallHandlingAssociation, $christmasCallHandlingAssociation, $newyearCallHandlingAssociation) -LanguageId "en-US" -TimeZoneId "Eastern Standard Time" -Operator $operatorEntity

获取许可证类型

Get-MgSubscribedSku

创建并分配资源帐户

  • ApplicationID
    • 自动助理: ce933385-9390-45d1-9512-c8d228074e07
    • 呼叫队列:11cd3e2e-fccb-42ad-ad00-878b93575e07
New-CsOnlineApplicationInstance -UserPrincipalName ContosoMainAA-RA@contoso.com -DisplayName "Contoso Main AA" -ApplicationID "ce933385-9390-45d1-9512-c8d228074e07"

Update-MgUser -UserId "ContosoMainAA-RA@contoso.com" -UsageLocation US

$Sku = Get-MgSubscribedSku -All | Where SkuPartNumber -eq 'contoso:PHONESYSTEM_VIRTUALUSER'
$addLicenses = @(
@{SkuId = $Sku.SkuId}
)

Set-MgUserLicense -UserId 'ContosoDialByNameAA-RA@contoso.com' -AddLicenses $addLicenses -RemoveLicenses @()

$applicationInstanceID = (Get-CsOnlineUser "ContosoMainAA-RA@contoso.com").Identity

$autoAttendantID = (Get-CsAutoAttendant -NameFilter "Contoso Main").Identity

New-CsOnlineApplicationInstanceAssociation -Identities @($applicationInstanceID) -ConfigurationID $autoAttendantID -ConfigurationType AutoAttendant

获取未分配的服务编号列表

Get-CsPhoneNumberAssignment -PstnAssignmentStatus Unassigned -CapabilitiesContain VoiceApplicationAssignment

分配可用电话号码

分配给电话号码的使用位置必须与分配给资源帐户的使用位置匹配。

Set-CsPhoneNumberAssignment -Identity ContosoMainAA-RA@contoso.com -PhoneNumber +{spare number from output of above command} -PhoneNumberType CallingPlan

按姓名拨号 自动助理 - 完成

创建拨号范围

$salesGroupID = Find-CsGroup -SearchQuery "Sales" | % { $_.Id }

$supportGroupID = Find-CsGroup -SearchQuery "Support" | % { $_.Id }

$dialScope = New-CsAutoAttendantDialScope -GroupScope -GroupIds @($salesGroupID, $supportGroupID)

创建提示和菜单选项

$dialByNameMenuPrompt = New-CsAutoAttendantPrompt -TextToSpeechPrompt "Please say or enter the name of the person you would like to reach. To return to the previous menu press 9."

$dialByNameMenuOption9Target = (Get-CsOnlineUser "ContosoMainAA-RA@contoso.com").Identity

$dialByNameMenuOption9Entity = New-CsAutoAttendantCallableEntity -Identity $dialByNameMenuOption9Target -Type applicationendpoint

$dialByNameMenuOption9 = New-CsAutoAttendantMenuOption -Action TransferCallToTarget -DtmfResponse Tone9 -CallTarget $dialByNameMenuOption9Entity

$dialByNameMenu = New-CsAutoAttendantMenu -Name "Contoso Dial By Name AA" -MenuOptions @($dialByNameMenuOption9) -Prompt $dialByNameMenuPrompt

$dialByNameMenu = New-CsAutoAttendantMenu -Name "Contoso Dial By Name AA" -MenuOptions @($dialByNameMenuOption9) -Prompt $dialByNameMenuPrompt -EnableDialByName -DirectorySearchMethod ByName

$dialByNameCallFlow = New-CsAutoAttendantCallFlow -Name "Contoso Dial By Name Call Flow" -Menu $dialByNameMenu

$dialByNameAutoAttendant = New-CsAutoAttendant -Name "Contoso Dial By Name" -DefaultCallFlow $dialByNameCallFlow -LanguageId "en-US" -TimeZoneId "UTC" -Operator $operatorEntity -EnableVoiceResponse -InclusionScope $dialScope

分配资源帐户

New-CsOnlineApplicationInstanceAssociation -Identities @($dialByNameApplicationInstanceID) -ConfigurationID $dialByNameAutoAttendant.Id -ConfigurationType AutoAttendant

规划 Teams 自动助理和呼叫队列

下面是你通过 Microsoft Teams 电话获得的福利

通过 cmdlet 创建呼叫队列