right  Talk To Us!

run speech menu Action

Runs an interactive menu that requests a word or short phrase, or a single digit key press from the call. You can set a prompt and the caller is expected to respond by saying a word or short phrase or pressing a single digit from a number of menu options. For example "Say your colour, blue or red, or press one for blue or two for red."

A run speech menu action uses one speech recognition stream. The service must be configured so that the application will have one stream available when the action runs. If the prompt play has barge in on speech enabled, it will share the speech recognition stream.

Note that speech recognition/transcription is a chargeable feature.

language wrappers and examples

The run speech menu properties are:

Property Required/Optional Default Description
menu options required An array of at least one speech menu option objects, each specifying word or phrase or a Dual Tone Multi Frequency (DTMF) digit and an associated next page.
prompt optional - A play action that prompts for a digit to be selected or word or short phrase to be said. Note that barge in phrases are ignored for this play action.
language
from API V2.0
optionalen-USA BCP 47 language code for the spoken menu options. Use a language code from the Speech Recognition Languages page. Available in REST API Version 2 and later.
speech model options
from API V2.0
optional - A speech model options object to select and configure the model used. Available in REST API Version 2 and later.
help digit optional "*" A single digit that, when pressed, will result in the menu prompt being repeated. An empty string signifies no help digit. Valid digits are 0123456789ABCD#*.
help word optional "help" A single word that, when said, will result in the menu prompt being repeated. An empty string signifies no help word.
seconds timeout
from API V2.0
optional 5 An integer. The time in seconds that the action waits for a response from the user after the prompt has finished. A value of 0 or a negative value signifies that this timeout is disabled.
on input timeout messages optional "Sorry, I did not get anything.",
"Please listen to the instructions, and then speak clearly or press the relevant digit."
An array of play actions. This defines messages to play if no input is recognised within the input timeout period. Each play action in the array is played once for each successive timeout. When all messages have been played the run speech menu action finishes. Note that barge in is disabled by default for these actions.
on invalid input messages optional "Sorry, that isn't valid input.",
"Please listen to the instructions, and then speak clearly or press the relevant digit."
An array of play actions. This defines messages to play if an invalid input is detected. Each play action in the array is played once for each successive invalid input. When all messages have been played the run speech menu action finishes. Note that barge in is disabled by default for these actions.

Remarks

run speech menu supports speaking or typing ahead. It inspects any digits or speech that may have already been cached from barge in on a preceding play action. If this input matches one of the menu options this action will return the selection immediately without playing the prompt.

To avoid this behaviour you can insert a clear input action after the play action.

Returns

The result of the menu selection will be returned via the subsequent http request to the selected next page in action result as follows:

PropertyAvailabilityDescription
selected speechalwaysA string containing the word or phrase of the menu option that was selected.
selected digitalwaysA string containing the single digit of the menu option that was selected.
selected input typealwaysA string indicating how the menu option was selected. Either 'speech' or 'digit'.



  • Examples:

    • Run a simple yes/no menu using the default parameters:

      "run_speech_menu" : 
      {
          "prompt" : 
          {
              "play" :
              {
                  "play_list" :
                  [
                      {
                          "text_to_say" : "Please say yes or no. Or press 1 for yes and 2 for no."
                      }
                  ]
              }
          },
          "menu_options" : 
          [
              {
                  "speech" : "yes",
                  "digit"  : "1",
                  "next_page" : 
                  {
                      "url" : "optionyespage"
                  }
              },
              {
                  "speech" : "no"
                  "digit"  : "2",
                  "next_page" : 
                  {
                      "url" : "optionnopage"
                  }
              }
          ]
      }
      

      The selected option is specified in the request for the next page:

      "action_result" :
      {
          "action" : "run_speech_menu",
          "result" :
          {
              "selected_speech" : "no",
              "selected_digit" : "2",
              "selected_input_type" : "speech"
          }
      }
      
    • Run a menu with three options, specifying non-default parameters:

      "run_speech_menu" : 
      {
          "prompt" : 
          {
              "play" :
              {
                  "play_list" :
                  [
                      {
                          "file_to_play" : "voicemailmenu.wav"
                      }
                  ]
              }
          },
          "menu_options" : 
          [
      		 "language" : "en-GB",
              {
                  "speech" : "one",
                  "digit"  : "1",
                  "next_page" : 
                  {
                      "url" : "voicemailoption1page"
                  }
              },
              {
                  "speech" : "two",
                  "digit"  : "2",
                  "next_page" : 
                  {
                      "url" : "voicemailoption2page"
                  }
              },
              {
                  "speech" : "three",
                  "digit"  : "3",
                  "next_page" : 
                  {
                      "url" : "voicemailoption3page"
                  }
              }
          ],
          "help_digit" : "#",
          "help_word"  : "repeat",
          "seconds_timeout" : 10,
          "on_input_timeout_messages" :
          [
              {
                  "play" :
                  {
                      "play_list" :
                      [   
                          {
                              "text_to_say" : "I didn't catch your entry."
                          }
                      ]
                  },
                  "play" :
                  {
                      "play_list" :
                      [   
                          {
                              "text_to_say" : "Please select an option."
                          }
                      ]
                  },
                  "play" :
                  {
                      "play_list" :
                      [   
                          {
                              "file_to_play" : "oneMoreTime.wav"
                          }
                      ]
                  }
              }
          ],
          "on_invalid_input_messages" : 
          [
              {
                  "play" :
                  {
                      "play_list" :
                      [   
                          {
                              "text_to_say" : "That wasn't one of the options. Please try again."
                          }
                      ]
                  },
                  "play" :
                  {
                      "play_list" :
                      [   
                          {
                              "file_to_play" : "oneMoreTime.wav"
                          }
                      ]
                  }
              }
          ]
      }
      

      The following may be returned when an option is selected:

      "action_result" :
      {
          "action" : "run_speech_menu",
          "result" :
          {
              "selected_speech" : "three",
              "selected_digit" : "3",
              "selected_input_type" : "digit"
          }
      }
      
  • RunSpeechMenu Class
    Namespace: Aculab.Cloud.RestAPIWrapper
    Assembly: Aculab.Cloud.RestAPIWrapper.dll

    An action to run a menu prompting the user for a selection via speech or a keypress.

    • public class RunSpeechMenu : TelephonyAction
      {
          // Constructors
          public RunSpeechMenu(List<SpeechMenuOption> options, Play prompt=null);
          [Obsolete] public RunSpeechMenu(Play prompt, List<SpeechMenuOption> options);
      
          // Members
          public string Language;
          public SpeechModelOptions SpeechModelOptions;
          public char HelpDigit;
          public string HelpWord;
          public int SecondsTimeout;
          public List<Play> OnInputTimeoutMessages;
          public List<Play> OnInvalidInputMessages;
      }
      

      Examples:

      • Run a simple yes/no menu using the default parameters:

        List<TelephonyAction> actions = new List<TelephonyAction>();
        
        var prompt = Play.SayText("Please say yes or no. Or press 1 for yes and 2 for no.");
        
        var menuOptions = new List<SpeechMenuOption>
        {
            new SpeechMenuOption("one", '1', new WebPageRequest("OptionYesPage.aspx")),
            new SpeechMenuOption("two", '2', new WebPageRequest("OptionNoPage.aspx"))
        };
        
        var runSpeechMenu = new RunSpeechMenu(menuOptions, prompt);
        
        actions.Add(runSpeechMenu);
        

        Obtain the selected option from the action's next page request:

        // Unpack the request
        var telephonyRequest = new TelephonyRequest(Request);
        
        var runSpeechMenuResult = (RunSpeechMenuResult)telephonyRequest.InstanceInfo.ActionResult;
        var selectedInputType = runSpeechMenuResult.SelectedInputType;
        var selectedDigit = runSpeechMenuResult.SelectedDigit;
        var selectedSpeech = runSpeechMenuResult.SelectedSpeech;
        
      • Run a menu with three options, specifying non-default parameters:

        List<TelephonyAction> actions = new List<TelephonyAction>();
        
        var prompt = Play.PlayFile("voicemailmenu.wav");
        
        var menuOptions = new List<SpeechMenuOption>
        {
            new SpeechMenuOption("one", '1', new WebPageRequest("VoicemailOption1.aspx")),
            new SpeechMenuOption("two", '2', new WebPageRequest("VoicemailOption2.aspx")),
            new SpeechMenuOption("three", '3', new WebPageRequest("VoicemailOption3.aspx"))
        };
        
        var runSpeechMenu = new RunSpeechMenu(menuOptions, prompt)
        {
            HelpDigit = '#',
            HelpWord = "repeat",
            SecondsTimeout = 10
        };
        
        var inputTimeoutMessages = new List<Play>
        {
            Play.SayText("I didn't catch your entry."),
            Play.SayText("Please select an option."),
            Play.PlayFile("oneMoreTime.wav")
        };
        runSpeechMenu.OnInputTimeoutMessages = inputTimeoutMessages;
        
        var invalidInputMessages = new List<Play>
        {
            Play.SayText("That wasn't one of the options. Please try again."),
            Play.PlayFile("oneMoreTime.wav")
        };
        runSpeechMenu.OnInvalidInputMessages = invalidInputMessages;
        
        actions.Add(runSpeechMenu);
        

        Obtain the selected option from the action's next page request:

        // Unpack the request
        var telephonyRequest = new TelephonyRequest(Request);
        
        var runSpeechMenuResult = (RunSpeechMenuResult)telephonyRequest.InstanceInfo.ActionResult;
        var selectedInputType = runSpeechMenuResult.SelectedInputType;
        var selectedDigit = runSpeechMenuResult.SelectedDigit;
        var selectedSpeech = runSpeechMenuResult.SelectedSpeech;
        
    • public class RunSpeechMenu : TelephonyAction
      {
          // Constructors
          public RunSpeechMenu(List<SpeechMenuOption> options, Play prompt=null);
          [Obsolete] public RunSpeechMenu(Play prompt, List<SpeechMenuOption> options);
      
          // Members
          public string Language;
          public SpeechModelOptions SpeechModelOptions;
          public char HelpDigit;
          public string HelpWord;
          public int SecondsTimeout;
          public List<Play> OnInputTimeoutMessages;
          public List<Play> OnInvalidInputMessages;
      }
      

      Examples:

      • Run a simple yes/no menu using the default parameters:

        List<TelephonyAction> actions = new List<TelephonyAction>();
        
        var prompt = Play.SayText("Please say yes or no. Or press 1 for yes and 2 for no.");
        
        var menuOptions = new List<SpeechMenuOption>
        {
            new SpeechMenuOption("one", '1', new WebPageRequest("OptionYesPage.aspx")),
            new SpeechMenuOption("two", '2', new WebPageRequest("OptionNoPage.aspx"))
        };
        
        var runSpeechMenu = new RunSpeechMenu(menuOptions, prompt);
        
        actions.Add(runSpeechMenu);
        

        Obtain the selected option from the action's next page request:

        // Unpack the request
        var telephonyRequest = new TelephonyRequest(Request);
        
        var runSpeechMenuResult = (RunSpeechMenuResult)telephonyRequest.InstanceInfo.ActionResult;
        var selectedInputType = runSpeechMenuResult.SelectedInputType;
        var selectedDigit = runSpeechMenuResult.SelectedDigit;
        var selectedSpeech = runSpeechMenuResult.SelectedSpeech;
        
      • Run a menu with three options, specifying non-default parameters:

        List<TelephonyAction> actions = new List<TelephonyAction>();
        
        var prompt = Play.PlayFile("voicemailmenu.wav");
        
        var menuOptions = new List<SpeechMenuOption>
        {
            new SpeechMenuOption("one", '1', new WebPageRequest("VoicemailOption1.aspx")),
            new SpeechMenuOption("two", '2', new WebPageRequest("VoicemailOption2.aspx")),
            new SpeechMenuOption("three", '3', new WebPageRequest("VoicemailOption3.aspx"))
        };
        
        var runSpeechMenu = new RunSpeechMenu(menuOptions, prompt)
        {
            HelpDigit = '#',
            HelpWord = "repeat",
            SecondsTimeout = 10
        };
        
        var inputTimeoutMessages = new List<Play>
        {
            Play.SayText("I didn't catch your entry."),
            Play.SayText("Please select an option."),
            Play.PlayFile("oneMoreTime.wav")
        };
        runSpeechMenu.OnInputTimeoutMessages = inputTimeoutMessages;
        
        var invalidInputMessages = new List<Play>
        {
            Play.SayText("That wasn't one of the options. Please try again."),
            Play.PlayFile("oneMoreTime.wav")
        };
        runSpeechMenu.OnInvalidInputMessages = invalidInputMessages;
        
        actions.Add(runSpeechMenu);
        

        Obtain the selected option from the action's next page request:

        // Unpack the request
        var telephonyRequest = new TelephonyRequest(Request);
        
        var runSpeechMenuResult = (RunSpeechMenuResult)telephonyRequest.InstanceInfo.ActionResult;
        var selectedInputType = runSpeechMenuResult.SelectedInputType;
        var selectedDigit = runSpeechMenuResult.SelectedDigit;
        var selectedSpeech = runSpeechMenuResult.SelectedSpeech;
        
    • public class RunSpeechMenu : TelephonyAction
      {
          // Constructors
          public RunSpeechMenu(List<SpeechMenuOption> options, Play prompt=null);
          [Obsolete] public RunSpeechMenu(Play prompt, List<SpeechMenuOption> options);
      
          // Members
          public string Language;
          public SpeechModelOptions SpeechModelOptions;
          public char HelpDigit;
          public string HelpWord;
          public int SecondsTimeout;
          public List<Play> OnInputTimeoutMessages;
          public List<Play> OnInvalidInputMessages;
      }
      

      Examples:

      • Run a simple yes/no menu using the default parameters:

        List<TelephonyAction> actions = new List<TelephonyAction>();
        
        var prompt = Play.SayText("Please say yes or no. Or press 1 for yes and 2 for no.");
        
        var menuOptions = new List<SpeechMenuOption>
        {
            new SpeechMenuOption("one", '1', new WebPageRequest("OptionYesPage.aspx")),
            new SpeechMenuOption("two", '2', new WebPageRequest("OptionNoPage.aspx"))
        };
        
        var runSpeechMenu = new RunSpeechMenu(menuOptions, prompt);
        
        actions.Add(runSpeechMenu);
        

        Obtain the selected option from the action's next page request:

        // Unpack the request
        var telephonyRequest = await TelephonyRequest.UnpackRequestAsync(Request);
        
        var runSpeechMenuResult = (RunSpeechMenuResult)telephonyRequest.InstanceInfo.ActionResult;
        var selectedInputType = runSpeechMenuResult.SelectedInputType;
        var selectedDigit = runSpeechMenuResult.SelectedDigit;
        var selectedSpeech = runSpeechMenuResult.SelectedSpeech;
        
      • Run a menu with three options, specifying non-default parameters:

        List<TelephonyAction> actions = new List<TelephonyAction>();
        
        var prompt = Play.PlayFile("voicemailmenu.wav");
        
        var menuOptions = new List<SpeechMenuOption>
        {
            new SpeechMenuOption("one", '1', new WebPageRequest("VoicemailOption1.aspx")),
            new SpeechMenuOption("two", '2', new WebPageRequest("VoicemailOption2.aspx")),
            new SpeechMenuOption("three", '3', new WebPageRequest("VoicemailOption3.aspx"))
        };
        
        var runSpeechMenu = new RunSpeechMenu(menuOptions, prompt)
        {
            HelpDigit = '#',
            HelpWord = "repeat",
            SecondsTimeout = 10
        };
        
        var inputTimeoutMessages = new List<Play>
        {
            Play.SayText("I didn't catch your entry."),
            Play.SayText("Please select an option."),
            Play.PlayFile("oneMoreTime.wav")
        };
        runSpeechMenu.OnInputTimeoutMessages = inputTimeoutMessages;
        
        var invalidInputMessages = new List<Play>
        {
            Play.SayText("That wasn't one of the options. Please try again."),
            Play.PlayFile("oneMoreTime.wav")
        };
        runSpeechMenu.OnInvalidInputMessages = invalidInputMessages;
        
        actions.Add(runSpeechMenu);
        

        Obtain the selected option from the action's next page request:

        // Unpack the request
        var telephonyRequest = await TelephonyRequest.UnpackRequestAsync(Request);
        
        var runSpeechMenuResult = (RunSpeechMenuResult)telephonyRequest.InstanceInfo.ActionResult;
        var selectedInputType = runSpeechMenuResult.SelectedInputType;
        var selectedDigit = runSpeechMenuResult.SelectedDigit;
        var selectedSpeech = runSpeechMenuResult.SelectedSpeech;
        
  • RunSpeechMenu Class
    Namespace: Aculab.Cloud.RestAPIWrapper
    Assembly: Aculab.Cloud.RestAPIWrapper.dll

    An action to run a menu prompting the user for a selection via speech or a keypress.

    • Public Class RunSpeechMenu
          Inherits TelephonyAction
      
          ' Constructors
          Public Sub New (options As List(Of Speechmenuoption), prompt=null As Play)
          [Obsolete] Public Sub New (prompt As Play, options As List(Of Speechmenuoption))
      
          ' Members
          Public Property Language As String
          Public Property SpeechModelOptions As Speechmodeloptions
          Public Property HelpDigit As Char
          Public Property HelpWord As String
          Public Property SecondsTimeout As Integer
          Public Property OnInputTimeoutMessages As List(Of Play)
          Public Property OnInvalidInputMessages As List(Of Play)
      End Class
      

      Examples:

      • Run a simple yes/no menu using the default parameters:

        Dim actions = New List(Of TelephonyAction)
        
        Dim prompt = Play.SayText("Please say yes or no. Or press 1 for yes and 2 for no.")
        
        Dim menuOptions = New List(Of SpeechMenuOption)
        menuOptions.Add(New SpeechMenuOption("one", "1", New WebPageRequest("OptionYesPage.aspx")))
        menuOptions.Add(New SpeechMenuOption("two", "2", New WebPageRequest("OptionNoPage.aspx")))
        
        Dim runSpeechMenu = New RunSpeechMenu(menuOptions, prompt)
        
        actions.Add(runSpeechMenu)
        

        Obtain the selected option from the action's next page request:

        ' Unpack the request
        Dim telephonyRequest = New TelephonyRequest(Request)
        
        Dim runSpeechMenuResult As RunSpeechMenuResult = telephonyRequest.InstanceInfo.ActionResult
        Dim selectedInputType = runSpeechMenuResult.SelectedInputType
        Dim selectedDigit = runSpeechMenuResult.SelectedDigit
        Dim selectedSpeech = runSpeechMenuResult.SelectedSpeech
        
      • Run a menu with three options, specifying non-default parameters:

        Dim actions = New List(Of TelephonyAction)
        
        Dim prompt = Play.PlayFile("voicemailmenu.wav")
        
        Dim menuOptions = New List(Of SpeechMenuOption)
        menuOptions.Add(New SpeechMenuOption("one", "1", New WebPageRequest("VoicemailOption1.aspx")))
        menuOptions.Add(New SpeechMenuOption("two", "2", New WebPageRequest("VoicemailOption2.aspx")))
        menuOptions.Add(New SpeechMenuOption("three", "3", New WebPageRequest("VoicemailOption3.aspx")))
        
        Dim runSpeechMenu = New RunSpeechMenu(menuOptions, prompt)
        runSpeechMenu.HelpDigit = "#"
        runSpeechMenu.HelpWord = "repeat"
        runSpeechMenu.SecondsTimeout = 10
        
        Dim inputTimeoutMessages = New List(Of Play)
        inputTimeoutMessages.Add(Play.SayText("I didn't catch your entry."))
        inputTimeoutMessages.Add(Play.SayText("Please select an option."))
        inputTimeoutMessages.Add(Play.PlayFile("oneMoreTime.wav"))
        runSpeechMenu.OnInputTimeoutMessages = inputTimeoutMessages
        
        Dim invalidInputMessages = New List(Of Play)
        invalidInputMessages.Add(Play.SayText("That wasn't one of the options. Please try again."))
        invalidInputMessages.Add(Play.PlayFile("oneMoreTime.wav"))
        runSpeechMenu.OnInvalidInputMessages = invalidInputMessages
        
        actions.Add(runSpeechMenu)
        

        Obtain the selected option from the action's next page request:

        ' Unpack the request
        Dim telephonyRequest = New TelephonyRequest(Request)
        
        Dim runSpeechMenuResult As RunSpeechMenuResult = telephonyRequest.InstanceInfo.ActionResult
        Dim selectedInputType = runSpeechMenuResult.SelectedInputType
        Dim selectedDigit = runSpeechMenuResult.SelectedDigit
        Dim selectedSpeech = runSpeechMenuResult.SelectedSpeech
        
    • Public Class RunSpeechMenu
          Inherits TelephonyAction
      
          ' Constructors
          Public Sub New (options As List(Of Speechmenuoption), prompt=null As Play)
          [Obsolete] Public Sub New (prompt As Play, options As List(Of Speechmenuoption))
      
          ' Members
          Public Property Language As String
          Public Property SpeechModelOptions As Speechmodeloptions
          Public Property HelpDigit As Char
          Public Property HelpWord As String
          Public Property SecondsTimeout As Integer
          Public Property OnInputTimeoutMessages As List(Of Play)
          Public Property OnInvalidInputMessages As List(Of Play)
      End Class
      

      Examples:

      • Run a simple yes/no menu using the default parameters:

        Dim actions = New List(Of TelephonyAction)
        
        Dim prompt = Play.SayText("Please say yes or no. Or press 1 for yes and 2 for no.")
        
        Dim menuOptions = New List(Of SpeechMenuOption)
        menuOptions.Add(New SpeechMenuOption("one", "1", New WebPageRequest("OptionYesPage.aspx")))
        menuOptions.Add(New SpeechMenuOption("two", "2", New WebPageRequest("OptionNoPage.aspx")))
        
        Dim runSpeechMenu = New RunSpeechMenu(menuOptions, prompt)
        
        actions.Add(runSpeechMenu)
        

        Obtain the selected option from the action's next page request:

        ' Unpack the request
        Dim telephonyRequest = New TelephonyRequest(Request)
        
        Dim runSpeechMenuResult As RunSpeechMenuResult = telephonyRequest.InstanceInfo.ActionResult
        Dim selectedInputType = runSpeechMenuResult.SelectedInputType
        Dim selectedDigit = runSpeechMenuResult.SelectedDigit
        Dim selectedSpeech = runSpeechMenuResult.SelectedSpeech
        
      • Run a menu with three options, specifying non-default parameters:

        Dim actions = New List(Of TelephonyAction)
        
        Dim prompt = Play.PlayFile("voicemailmenu.wav")
        
        Dim menuOptions = New List(Of SpeechMenuOption)
        menuOptions.Add(New SpeechMenuOption("one", "1", New WebPageRequest("VoicemailOption1.aspx")))
        menuOptions.Add(New SpeechMenuOption("two", "2", New WebPageRequest("VoicemailOption2.aspx")))
        menuOptions.Add(New SpeechMenuOption("three", "3", New WebPageRequest("VoicemailOption3.aspx")))
        
        Dim runSpeechMenu = New RunSpeechMenu(menuOptions, prompt)
        runSpeechMenu.HelpDigit = "#"
        runSpeechMenu.HelpWord = "repeat"
        runSpeechMenu.SecondsTimeout = 10
        
        Dim inputTimeoutMessages = New List(Of Play)
        inputTimeoutMessages.Add(Play.SayText("I didn't catch your entry."))
        inputTimeoutMessages.Add(Play.SayText("Please select an option."))
        inputTimeoutMessages.Add(Play.PlayFile("oneMoreTime.wav"))
        runSpeechMenu.OnInputTimeoutMessages = inputTimeoutMessages
        
        Dim invalidInputMessages = New List(Of Play)
        invalidInputMessages.Add(Play.SayText("That wasn't one of the options. Please try again."))
        invalidInputMessages.Add(Play.PlayFile("oneMoreTime.wav"))
        runSpeechMenu.OnInvalidInputMessages = invalidInputMessages
        
        actions.Add(runSpeechMenu)
        

        Obtain the selected option from the action's next page request:

        ' Unpack the request
        Dim telephonyRequest = New TelephonyRequest(Request)
        
        Dim runSpeechMenuResult As RunSpeechMenuResult = telephonyRequest.InstanceInfo.ActionResult
        Dim selectedInputType = runSpeechMenuResult.SelectedInputType
        Dim selectedDigit = runSpeechMenuResult.SelectedDigit
        Dim selectedSpeech = runSpeechMenuResult.SelectedSpeech
        
  • class RunSpeechMenu extends TelephonyAction

    Represents a run speech menu action.

    Class synopsis:

    // Constructors:
    public RunSpeechMenu(Play prompt, List<SpeechMenuOption> options)
    public RunSpeechMenu(List<SpeechMenuOption> options)
    
    // Members:
    public void setPrompt(Play prompt)
    public void setLanguage(String language)
    public void setSpeechModelOptions(SpeechModelOptions speechModelOptions)
    public void setHelpWord(String helpWord)
    public void setHelpDigit(char helpDigit)
    public void setSecondsTimeout(int secondsTimeout)
    public void setOnInputTimeoutMessages(List<Play> messageList)
    public void setOnInvalidInputMessages(List<Play> messageList)
    public JSONObject toJSONObject()
    
    class RunSpeechMenuResult extends ActionResult

    Represents the result of a run speech menu action.

    Class synopsis:

    // Members:
    public String getSelectedSpeech()
    public char getSelectedDigit()
    public String getSelectedInputType()
    

    Examples:

    • Run a simple yes/no menu using the default parameters:

      List<TelephonyAction> actions = new ArrayList<TelephonyAction>();
      
      Play prompt = Play.sayText("Please say yes or no, or press 1 for yes or 2 for no.");
      List<SpeechMenuOption> options = new ArrayList<SpeechMenuOption>();
      options.add(new SpeechMenuOption("yes", '1', new WebPageRequest("optionyespage")));
      options.add(new SpeechMenuOption("no", '2', new WebPageRequest("optionnopage")));
      
      actions.add(new RunSpeechMenu(prompt, options));
      

      Obtain the selected option from the action's next page request:

      TelephonyRequest ourRequest = new TelephonyRequest(request);
      RunSpeechMenuResult menuResult = (RunSpeechMenuResult)ourRequest.getInstanceInfo().getActionResult();
      char selectedDigit = menuResult.getSelectedDigit();
      String selectedSpeech = menuResult.getSelectedSpeech();
      
    • Run a menu with three options, specifying non-default parameters:

      List<TelephonyAction> actions = new ArrayList<TelephonyAction>();
      
      Play prompt = Play.playFile("voicemailmenu.wav");
      
      List<SpeechMenuOption> options = new ArrayList<SpeechMenuOption>();
      options.add(new SpeechMenuOption("one", '1', new WebPageRequest("voicemailoption1page")));
      options.add(new SpeechMenuOption("two", '2', new WebPageRequest("voicemailoption2page")));
      options.add(new SpeechMenuOption("three", '3', new WebPageRequest("voicemailoption3page")));
      
      // Set up info messages for digit timeout
      List<Play> onInputTimeoutMessages = new ArrayList<Play>();
      onInputTimeoutMessages.add(Play.sayText("I didn't catch your entry."));
      onInputTimeoutMessages.add(Play.sayText("Please select an option."));
      onInputTimeoutMessages.add(Play.playFile("oneMoreTime.wav"));
      // Set up info messages for invalid input
      List<Play> onInvalidInputMessages = new ArrayList<Play>();
      onInvalidInputMessages.add(Play.sayText("That wasn't one of the options. Please try again."));
      onInvalidInputMessages.add(Play.playFile("oneMoreTime.wav"));
      
      RunSpeechMenu runSpeechMenuAction = new RunSpeechMenu(prompt, options);
      runSpeechMenuAction.setLanguage("en-GB");
      runSpeechMenuAction.setHelpDigit('#');
      runSpeechMenuAction.setHelpWord("repeat");
      runSpeechMenuAction.setSecondsTimeout(10);
      runSpeechMenuAction.setOnInputTimeoutMessages(onInputTimeoutMessages);
      runSpeechMenuAction.setOnInvalidInputMessages(onInvalidInputMessages);
      
      actions.add(runSpeechMenuAction);
      

      Obtain the selected option from the action's next page request:

      TelephonyRequest ourRequest = new TelephonyRequest(request);
      RunSpeechMenuResult menuResult = (RunSpeechMenuResult)ourRequest.getInstanceInfo().getActionResult();
      char selectedDigit = menuResult.getSelectedDigit();
      String selectedSpeech = menuResult.getSelectedSpeech();
      
  • class RunSpeechMenu

    Represents a run menu action.

    Class synopsis:

    # RunSpeechMenu object:
    RunSpeechMenu(menu_options)
    
    # Instance methods:
    RunSpeechMenu.set_prompt(play_action)
    RunSpeechMenu.set_language(language)
    RunSpeechMenu.set_speech_model_options(speech_model_options)
    RunSpeechMenu.set_help_digit(help_digit)
    RunSpeechMenu.set_help_word(word)
    RunSpeechMenu.set_seconds_timeout(timeout)
    RunSpeechMenu.set_on_input_timeout_messages(list_of_play_actions)
    RunSpeechMenu.set_on_invalid_input_messages(list_of_play_actions)
    RunSpeechMenu.append_speech_menu_option(speech_menu_option)
    
    Run Speech Menu Result

    The Run Speech Menu Result is represented by a dictionary. It is found within the action result for the next page.

    Obtaining the Run Speech Menu Result dictionary:

    my_request = TelephonyRequest(request)
    action_result = my_request.get_action_result()
    if action_result.get("action") == "run_speech_menu":
        run_speech_menu_result =  action_result.get("result")
    

    Examples:

    • Run a simple yes/no menu using the default parameters:

      # Create a list of actions that will be passed to the TelephonyResponse constructor
      list_of_actions = []
      
      speech_menu_opts = []
      speech_menu_opts.append(SpeechMenuOption('yes', '1', WebPage(url='option_yes_page')))
      speech_menu_opts.append(SpeechMenuOption('no', '2', WebPage(url='option_no_page')))
      
      speech_menu_action = RunSpeechMenu(speech_menu_opts)
      speech_menu_action.set_prompt(Play(text_to_say='Please say yes or no. Or press 1 for yes and 2 for no.'))
      
      list_of_actions.append(speech_menu_action)
      

      Obtain the selected option from the action's next page request:

      my_request = TelephonyRequest(request)
      action_result = my_request.get_action_result()
      
      if action_result.get("action") == "run_speech_menu":
      
          run_menu_result =  action_result.get("result")
          selected_speech = run_menu_result.get("selected_speech")
          selected_digit = run_menu_result.get("selected_digit")
          selected_input_type = run_menu_result.get("selected_input_type")
      
          # Your code here...
      
    • Run a menu with three options, specifying non-default parameters:

      # Create a list of actions that will be passed to the TelephonyResponse constructor
      list_of_actions = []
      
      speech_menu_opts = []
      speech_menu_opts.append(SpeechMenuOption('1', 'one', WebPage(url='voicemail_option1_page')))
      speech_menu_opts.append(SpeechMenuOption('2', 'two', WebPage(url='voicemail_option2_page')))
      speech_menu_opts.append(SpeechMenuOption('3', 'three', WebPage(url='voicemail_option3_page')))
      
      timeout_messages = []
      timeout_messages.append(Play(text_to_say="I didn't catch your entry."))
      timeout_messages.append(Play(text_to_say="Please select an option."))
      timeout_messages.append(Play(file_to_play="oneMoreTime.wav"))
      
      invalid_messages = []
      invalid_messages.append(Play(text_to_say="That wasn't one of the options. Please try again."))
      invalid_messages.append(Play(file_to_play="oneMoreTime.wav"))
      
      speech_menu_action = RunSpeechMenu(speech_menu_opts)
      speech_menu_action.set_prompt(Play(file_to_play='voicemailmenu.wav'))
      speech_menu_action.set_language("en-GB")
      speech_menu_action.set_help_digit('#')
      speech_menu_action.set_help_word('repeat')
      speech_menu_action.set_seconds_timeout(10)
      speech_menu_action.set_on_input_timeout_messages(timeout_messages)
      speech_menu_action.set_on_invalid_input_messages(invalid_messages)
      
      list_of_actions.append(speech_menu_action)
      

      Obtain the selected option from the action's next page request:

      my_request = TelephonyRequest(request)
      action_result = my_request.get_action_result()
      
      if action_result.get("action") == "run_speech_menu":
      
          run_menu_result =  action_result.get("result")
          selected_speech = run_menu_result.get("selected_speech")
          selected_digit = run_menu_result.get("selected_digit")
          selected_input_type = run_menu_result.get("selected_input_type")
      
          # Your code here...
      
  • The RunSpeechMenu class

    Introduction

    Represents a run speech menu action.

    Class synopsis

    class RunSpeechMenu extends GetInputBase {
    
        /* methods */
        public __construct(array $opts = null)
        public self setHelpWord(string $word)
        public self setLanguage(string $lang)
        public self setSpeechModelOptions(SpeechModelOptions $opts)
        public self addSpeechMenuOption(
            string $speech,
            string $digit,
            WebPageRequest|string $next_page,
            string $method = null
        )
    
        /* inherited methods */
        public self setPrompt(Play $prompt)
        public self setHelpDigit(string $digit)
        public self setOnInputTimeoutMessages(MessageList $messages)
        public self setOnInvalidInputMessages(MessageList $messages)
        public self setSecondsTimeout(int $secs)
    }
    
    The RunSpeechMenuResult class

    Introduction

    Represents the result of a run speech menu action.

    Class synopsis

    class RunSpeechMenuResult extends ActionResult {
    
        /* methods */
        public string getSelectedDigit()
        public string getSelectedSpeech()
        public string getSelectedInputType()
    
        /* inherited methods */
        public string getAction()
        public boolean getInterrupted()
    }
    

    Examples:

    • Run a simple yes/no menu using the default parameters:

      $mp = new Aculab\TelephonyRestAPI\Play();
      $mp->addText('Please say yes or no. Or press 1 for yes and 2 for no.');
      $menu = new Aculab\TelephonyRestAPI\RunSpeechMenu();
      $menu->setPrompt($mp);
      $menu->addSpeechMenuOption('one', '1', 'optionyespage');
      $menu->addSpeechMenuOption('two', '2', 'optionnopage');
      $response->addAction($menu);
      

      Obtain the selected option from the action's next page request:

      $info = InstanceInfo::getInstanceInfo();
      $speechMenuResult = $info->getActionResult();
      $selectedInputType = $speechMenuResult->getSelectedInputType();
      $selectedDigit = $speechMenuResult->getSelectedDigit();
      $selectedSpeech = $speechMenuResult->getSelectedSpeech();
      
    • Run a menu with three options, specifying non-default parameters:

      $mp = new Aculab\TelephonyRestAPI\Play();
      $mp->addFile('voicemailmenu.wav');
      $menu = new Aculab\TelephonyRestAPI\RunSpeechMenu();
      $menu->setPrompt($mp);
      $menu->addSpeechMenuOption('one', '1', 'voicemailOption1Page');
      $menu->addSpeechMenuOption('two', '2', 'voicemailOption2Page');
      $menu->addSpeechMenuOption('three', '3', 'voicemailOption3Page');
      $menu->setHelpDigit('#');
      $menu->setHelpWord('repeat');
      $menu->setSecondsTimeout(10);
      
      $onInputTimeoutMessages = new Aculab\TelephonyRestAPI\MessageList();
      $onInputTimeoutMessages->addMessage(Aculab\TelephonyRestAPI\Play::sayText("I didn't catch your entry."));
      $onInputTimeoutMessages->addMessage(Aculab\TelephonyRestAPI\Play::sayText('Please select an option.'));
      $onInputTimeoutMessages->addMessage(Aculab\TelephonyRestAPI\Play::playFile('oneMoreTime.wav'));
      $menu->setOnInputTimeoutMessages($onInputTimeoutMessages);
      
      $onInvalidInputMessages = new Aculab\TelephonyRestAPI\MessageList();
      $onInvalidInputMessages->addMessage(Aculab\TelephonyRestAPI\Play::sayText("That wasn't one of the options. Please try again."));
      $onInvalidInputMessages->addMessage(Aculab\TelephonyRestAPI\Play::playFile('oneMoreTime.wav'));
      $menu->setOnInvalidInputMessages($onInvalidInputMessages);
      
      $response->addAction($menu);
      

      Obtain the selected option from the action's next page request:

      $info = InstanceInfo::getInstanceInfo();
      $speechMenuResult = $info->getActionResult();
      $selectedInputType = $speechMenuResult->getSelectedInputType();
      $selectedDigit = $speechMenuResult->getSelectedDigit();
      $selectedSpeech = $speechMenuResult->getSelectedSpeech();