Click or drag to resize

VoiceResourceGetDigits Method (Int32, Int32, String, Int32)

Waits for a user input as Digit(s) specifying four settings for the Voice Resource: Maximum Digits, Maximum Time, Termination Digit and Inter Digit Timeout.

Namespace:  VoiceElements.Client
Assembly:  VoiceElementsClient (in VoiceElementsClient.dll) Version:
public TerminationCode GetDigits(
	int maximumDigits,
	int maximumTime,
	string terminationDigits,
	int interDigitTimeout


Type: SystemInt32
The maximum number of digits that will be accepted from the caller. For more information, and an alternative way to set this property, see Maximum Digits Voice Resource Property.
Type: SystemInt32
The number of seconds to wait for the entire expected string of digits to be received. For more information, and an alternative way to set this property, see Maximum Time Voice Resource Property.
Type: SystemString
This digit, like a pound sign (#) would stop the code from waiting for more digits in a string. Note that using the "@" wildcard can be done here to denote any digit. This is especially helpful when getting a variable length or long string of input from a caller. For more information, and an alternative way to set this property, see Termination Digit Voice Resource Property.
Type: SystemInt32
This is the number of seconds between digits in a string that will cause Get Response to terminate and consider the input of the string complete. For more information, and an alternative way to set this property, see Inter-Digit Timeout Voice Resource Property.

Return Value

Type: TerminationCode
A Termination Code indicating how the wait ended. Typically, you will use this to determine what to do next.
This method sets four out of five of the Voice Resource properties for how long to wait, what Digits to expect, etc. For the remaining properties, whatever has been set in the VR properties will be used to determine the behavior of your waiting for a Digits using this overload. In the sample code below, these properties are specifically set before calling Get Digits.

Voice Resource Properties and Overloads

This method has three additional overloads allowing you to set specific Voice Resource properties to control behavior, or none at all. Before choosing, you will want to review the No Parameter Get Digits Overload, the Three Parameter Get Digits Overload and the Five Parameter Get Digits Overload. If you choose to use this method and not one of the overloads, keep in mind that you should set the Voice Resource properties before calling Get Digits. The only additional relevant property not included in this overload you need to consider is:

  • Clear Digit Buffer Flag - If set to true, digits in the buffer will be purged before the wait for Digits begins. Use this to clear any residual input you think might be in the buffer.

Get Digits vs Get Response: Speech Recognition

This method will only capture DTMF Digits. It has been replces by Get Response and its respective overloads which support digits and Speech Recognition.

This Method is Obsolete. Tip: Use Get Response

It is advised to use Get Response instead of this method.

The following sample code sets up a Channel Resource, Dials a Call, retrieves a Voice Resource, sets up some properties for a Voice Resource object and executes a Get Digits with a max digits of 11, max time of 20 seconds, a pound sign termination at the end and a 3 second inter-digit timeout.
public void DialAndGetDigits()
  // To get a channel, you must first get a link to a Telephony Server.  You may need to pass a username password here.
  TelephonyServer m_TelephonyServer = new TelephonyServer();

  // Get your channel resource from the server
  ChannelResource m_ChannelResource = m_TelephonyServer.GetChannel();

  // Example 1: Dial an oubound call
  string phoneNumber = "2135551212";

  // Get the voice resource and store in a variable for local use
  VoiceResource m_VoiceResource = m_ChannelResource.VoiceResource;

  // Setup the basic settings for the Voice Resource
  m_VoiceResource.ClearDigitBuffer = true;
  m_VoiceResource.TerminationDigits = "@"; // "@" or "ANY" can denote terminate a play on any digit received
  m_VoiceResource.Codec = Codec.MULAW_8Khz_8Bit;
  m_VoiceResource.DataFormat = DataFormat.Raw;

  // Set a termination code variable we will use to switch on Digits
  TerminationCode tc = TerminationCode.Normal;

  // Play a file
  tc = m_VoiceResource.Play(@"Introduction.wav");

  // Set the digit buffer to retain digits during the first play
  m_VoiceResource.ClearDigitBuffer = false;

  // Play some options to the caller, which will require input back from them
  tc = m_VoiceResource.Play(@"InputOptions.wav");

  // Execute GetDigits with max digits of 11, max time of 20 seconds and a pound sign termination digit, inter digit timeout is 3 seconds
  tc = m_VoiceResource.GetDigits(11, 20, "#", 3);

  // Insert your code here to process based on the termination code. and move on with your application
See Also