Click or drag to resize

ChannelResourceAnswer Method

This method is used to pickup an inbound call received on a Channel Resource.

Namespace:  VoiceElements.Client
Assembly:  VoiceElementsClient (in VoiceElementsClient.dll) Version: 8.6.1.1
Syntax
public void Answer()
Remarks
Typically, this method is called within the code you have built either inside of the New Inbound Call Event or in a class you call from that event. When the new call is received, use this method before continuing your call processing and executing any other methods like Plays.
Examples
The example below shows a chunk of code that executes when a New Inbound Call Event arrives. Notice that the sample immediately begins gathering information from the ChannelResource object reference passed in the NewCallEventArgs object "e". The code then Answers the call using this method a few lines in. This code also creates and instance of an IVR application class and executes an RunScript method, this is included to provide guidence and context.
static void s_TelephonyServer_NewCall(object sender, VoiceElements.Client.NewCallEventArgs e)
{
try
{
Log.Write("NewCall Arrival! DNIS: {0}  ANI: {1}  Caller ID Name: {2}", e.ChannelResource.Dnis, e.ChannelResource.Ani, e.ChannelResource.CallerIdName);

// Immediately subscribe to disconnects (hang ups), unles you have a specific reason to not see these events.
e.ChannelResource.Disconnected += new Disconnected(ChannelResource_Disconnected);

Log.Write("Answering...");
// Use the channel resource passed in with the event args to answer the call.
e.ChannelResource.Answer();

Log.Write("Calling My IVR Application");
// Call a class you have created which contains all the scripting and features of the voice interface for the call.
// You will find that this class will nee references to the Telephony Server, Channel Resource and Log.  You may add more depending on your application.
MyIVRApplication ivrApp = new MyIVRApplication(s_TelephonyServer, e.ChannelResource, Log);
// Call a method in your main telephony IVR class to execute your scripts
ivrApp1.RunScript();
}
catch (HangupException)
{
Log.Write("The Caller Hung Up.");
}
catch (Exception ex)
{
Log.WriteException(ex, "IvrApplication::NewCall");
}
finally
{
try
{
// Unsubscribe the disconnected event.
try { e.ChannelResource.Disconnected -= new Disconnected(ChannelResource_Disconnected); }
catch { }
// Force a Hangup for a safety net
try { e.ChannelResource.Disconnect(); }
catch { }
// Always Dispose of the channel resource object you got along with the initial event for safety.
try { e.ChannelResource.Dispose(); }
catch { }
Log.Write("Call complete.");
}
catch(Exception ex)
{
Log.WriteException(ex, "Error in finally block");
}
}
}
See Also