Click or drag to resize

VoiceResourceGetResponse Method

Waits for a user response as Digit(s) or Speech using all current settings for the Voice Resource, and therefore has no parameters.

Namespace:  VoiceElements.Client
Assembly:  VoiceElementsClient (in VoiceElementsClient.dll) Version: 8.6.1.1
Syntax
public TerminationCode GetResponse()

Return Value

Type: TerminationCode
A Termination Code indicating how the wait ended. Typically, you will use this to determine what to do next.
Remarks
This method does not set any of the required Voice Resource properties for how long to wait, what response to expect, etc. Whatever has been set in the VR properties will be used to determine the behavior of your waiting for a response using this overload. In the sample code below, these properties are specifically set before calling Get Response.

Voice Resource Properties and Overloads

This method has three additional overloads allowing you to set specific Voice Resource properties to control behavior. Before choosing, you will want to review the Three Parameter Get Response Overload, the Four Parameter Get Response Overload and the Five Parameter Get Response Overload. If you choose to use this method and not one of the overloads, keep in mind that you have set the Voice Resource properties before calling Get Response. The relevant properties you need to consider are:

  • Maximum Digits Property - The maximum number of digits that will be accepted from the caller.
  • Maximum Time Property - The number of seconds to wait for the entire expected string of digits to be received.
  • Termination Digit Property - This digit, like a pound sign (#) would stop the response from waiting for more digits in a string. Note that using the "@" wildcard can be done here to denote any digit.
  • Inter-Digit Timeout Property - 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.
  • Clear Digit Buffer Flag - If set to true, digits in the buffer will be purged before the wait for response begins. Use this to clear any residual input you think might be in the buffer.

Getting Speech Recognition Responses

This method will also return a word or string of word from a Speech Recognition Engine. What is returned can be retrieved using the Returned Word Property. In addition, you will need to define grammars, and set Speech Recognition Active property among other settings to properly use speech. More information on speech can be found on our Support Wiki.

Examples
The following sample code sets up a Channel Resource, Dials a Call, retrieves a Voice Resource, sets up the common properties for a Voice Resource object and executes a Get Response at the end.
public void DialAndGetResponse()
{
    // 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";
    m_ChannelResource.Dial(phoneNumber);

    // 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.MaximumDigits = 11;
    m_VoiceResource.Codec = Codec.MULAW_8Khz_8Bit;
    m_VoiceResource.DataFormat = DataFormat.Raw;

    // Set a termination code variable we will use to switch on response
    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");

    // Set the max time on the voice resource and termination digit.
    // Alternately, you can use overloads of GetResponse with parameters to specifically set these.
    m_VoiceResource.MaximumTime = 20;
    m_VoiceResource.TerminationDigits = "#";

    // Execute GetResponse with all of the above Voice Resource behaviors set.
    tc = m_VoiceResource.GetResponse();

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