Forum Discussion

JFM_12's avatar
JFM_12
Iron Contributor
Aug 22, 2024

Create powershelle for MenuOptions

Hello
Do you have a powershell script to create in AutoAttendant in CallFlow

a greeting message and 3 menu options

- 2 with a number

- 1 with redirection to CQ

Regards

JFM_12

  • Hello 
    I managed to create a script but it keeps asking for a greeting and also the country code is not accepted although it works.

     

    $attendantName = "x"
    $autoAttendant = Get-CsAutoAttendant -NameFilter $attendantName | Where-Object Name -eq $attendantName
    $callableEntity1 = New-CsAutoAttendantCallableEntity -Identity "tel:+4112345" -Type ExternalPSTN
    $menuOption = New-CsAutoAttendantMenuOption -Action TransferCallToTarget -DtmfResponse Tone1 -CallTarget $callableEntity1
    $menuPrompt = New-CsAutoAttendantPrompt -TextToSpeechPrompt "To reach our sales department, please press 1, or say operator to be redirected to our company switchboard"
    $menu = New-CsAutoAttendantMenu -Name "Default Menu" -MenuOptions @($menuOption) -Prompts @($menuPrompt)
    $greeting = New-CsAutoAttendantPrompt -ActiveType None -TextToSpeechPrompt 
    $callFlow = New-CsAutoAttendantCallFlow -Name "Default Call Flow" -Menu $menu -Greetings $greeting
    $autoAttendant.DefaultCallFlow = $callFlow
    Set-CsAutoAttendant -Instance $autoAttendant

     

     

    I was able to resolve the problems.

     

    Regards
    JFM_12

  • JFM_12 - Thanks for reporting your issue. 

    Use the New-CsAutoAttendantCallFlow cmdlet to create a new call flow.

     
    Syntax:
    New-CsAutoAttendantCallFlow
       -Name <String>
       -Menu <Object>
       [-Greetings <List>]
       [-Tenant <Guid>]
       [-ForceListenMenuEnabled]
       [<CommonParameters>]


    Ref Doc: New-CsAutoAttendantCallFlow (MicrosoftTeamsPowerShell) | Microsoft Learn

    Thanks, 

    Nivedipa

    ------------------------------------------------------------------------------------------ 

    If the response is helpful, please click "**Mark as Best Response**" and like it. You can share your feedback via Microsoft Teams Developer Feedback link. Click here to escalate. 

    • JFM_12's avatar
      JFM_12
      Iron Contributor

      Nivedipa-MSFT 

      Hello

      Hope you are having a great day. Thank you very much.


      I tried to do the script, but keep getting errors

       

      $menuOptions = @(
      $autoAttendant = Get-CsAutoAttendant -Identity "xxxx"
      #$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 = "tel:+1234567"
      $openHoursMenuOption1Entity = New-CsAutoAttendantCallableEntity -Identity $openHoursMenuOption1Target -Type ExternalPstn
      $openHoursMenuOption1 = New-CsAutoAttendantMenuOption -Action TransferCallToTarget -DtmfResponse Tone1 -CallTarget $openHoursMenuOption1Entity
      $languageId = "de-DE"
      )
      
      $autoAttendant = $menuOptions
      Set-CsAutoAttendant -Instance $autoAttendant 

       

       

      But do get following error

       

      cmdlet Set-CsAutoAttendant at command pipeline position 1
      Supply values for the following parameters:
      Identity: 220caebb-8cf8-49c3-acbf-d82a366a41c4
      Microsoft.Teams.ConfigAPI.Cmdlets.internal\Set-CsAutoAttendant : The specified language ID is invalid. Please give correct parameter value.
      At C:\Program Files\WindowsPowerShell\Modules\MicrosoftTeams\5.5.0\custom\Merged_custom_PsExt.ps1:8476 char:13
      + $internalOutput = Microsoft.Teams.ConfigAPI.Cmdlets.inter ...
      + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      + CategoryInfo : InvalidOperation: ({ Identity = 22...AutoAttendant }:<>f__AnonymousType77`2) [Set-CsAutoAttendant_SetExpanded], UndeclaredResponseException
      + FullyQualifiedErrorId : BadRequest,Microsoft.Teams.ConfigAPI.Cmdlets.Generated.Cmdlets.SetCsAutoAttendant_SetExpanded

       

      Trying an alternativ gives me another error

       

      $autoAttendant = Get-CsAutoAttendant -Identity "xxx"
      $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 = "tel:+1234567"
      $openHoursMenuOption1Entity = New-CsAutoAttendantCallableEntity -Identity "tel:+41794002069" -Type ExternalPSTN
      $openHoursMenuOption1 = New-CsAutoAttendantMenuOption -Action TransferCallToTarget -DtmfResponse Tone1 -CallTarget $openHoursMenuOption1Entity
      $languageId = "de-DE"
      $autoAttendant.CallFlows += @($openHoursMenuOption1)
      Set-CsAutoAttendant -Instance $autoAttendant

       

      Exception setting "CallFlows": "Cannot convert the "Microsoft.Rtc.Management.Hosted.OAA.Models.MenuOption" value of type "Microsoft.Rtc.Management.Hosted.OAA.Models.MenuOption" to type "Microsoft.Rtc.Management.Hosted.OAA.Models.CallFlow"."

       

      Regards
      JFM_12

      • JFM_12's avatar
        JFM_12
        Iron Contributor

        Hello 
        I managed to create a script but it keeps asking for a greeting and also the country code is not accepted although it works.

         

        $attendantName = "x"
        $autoAttendant = Get-CsAutoAttendant -NameFilter $attendantName | Where-Object Name -eq $attendantName
        $callableEntity1 = New-CsAutoAttendantCallableEntity -Identity "tel:+4112345" -Type ExternalPSTN
        $menuOption = New-CsAutoAttendantMenuOption -Action TransferCallToTarget -DtmfResponse Tone1 -CallTarget $callableEntity1
        $menuPrompt = New-CsAutoAttendantPrompt -TextToSpeechPrompt "To reach our sales department, please press 1, or say operator to be redirected to our company switchboard"
        $menu = New-CsAutoAttendantMenu -Name "Default Menu" -MenuOptions @($menuOption) -Prompts @($menuPrompt)
        $greeting = New-CsAutoAttendantPrompt -ActiveType None -TextToSpeechPrompt 
        $callFlow = New-CsAutoAttendantCallFlow -Name "Default Call Flow" -Menu $menu -Greetings $greeting
        $autoAttendant.DefaultCallFlow = $callFlow
        Set-CsAutoAttendant -Instance $autoAttendant

         

         

        I was able to resolve the problems.

         

        Regards
        JFM_12

Resources