SignalWire.Relay.Calling.Call
All calls in SignalWire have a common generic interface, Call
. A Call
is a connection between SignalWire and another device.
Properties​
Name | Type | Description |
---|---|---|
ID | string | The unique identifier of the call. |
Type | string | The type of call. Only phone is currently supported. |
State | SignalWire.Relay.Calling.CallState | The current state of the call. |
PreviousState | SignalWire.Relay.Calling.CallState | The previous state of the call. |
Context | string | The context the call belongs to. |
Peer | SignalWire.Relay.Calling.Call | The call your original call is connected to. |
Active | bool | Indicates the call is active. |
Ended | bool | Indicates the call has ended. |
Answered | bool | Indicates the call has been answered. |
Busy | bool | Indicates the call ended with a busy signal. |
Methods​
AMD​
Alias for DetectAnsweringMachine
.
AMDAsync​
Alias for DetectAnsweringMachineAsync
.
Answer​
Answer an inbound call.
Parameters
None
Returns
SignalWire.Relay.Calling.AnswerResult
- The result object to interact with.
Examples
Answer an inbound call and check if it was successful.
AnswerResult resultAnswer = call.Answer();
if (resultAnswer.Successful) {
// The call has been answered
}
Connect​
Attempt to connect an existing call to a new outbound call and waits until one of the remote parties answers the call or the connect fails.
This method involves complex nested parameters.
You can connect to multiple devices in series, parallel, or any combination of both with creative use of the parameters. Series implies one device at a time, while parallel implies multiple devices at the same time.
Parameters
Parameter | Type | Required | Description |
---|---|---|---|
devices | List<List<SignalWire.Relay.Calling.CallDevice >> | required | A nested list of devices. Outer list is dialed in series, while inner list is called in parallel to each other. |
ringback | List<SignalWire.Relay.Calling.CallMedia > | optional | A list of ringback media to be played while waiting for the call to be answered. |
Returns
SignalWire.Relay.Calling.ConnectResult
- The result object to interact with.
Examples
Trying to connect a call by calling in series +18991114444 and +18991114445.
ConnectResult resultConnect = call.Connect(new List<List<CallDevice>>
{
new List<CallDevice>
{
new CallDevice
{
Type = CallDevice.DeviceType.phone,
Parameters = new CallDevice.PhoneParams
{
ToNumber = "+18991114444",
FromNumber = "+1YYYYYYYYYY",
Timeout = 30,
}
}
},
new List<CallDevice>
{
new CallDevice
{
Type = CallDevice.DeviceType.phone,
Parameters = new CallDevice.PhoneParams
{
ToNumber = "+18991114445",
FromNumber = "+1YYYYYYYYYY",
Timeout = 20,
}
}
}
},
ringback: new List<CallMedia>
{
new CallMedia
{
Type = CallMedia.MediaType.ringtone,
Parameters = new CallMedia.RingtoneParams
{
Name = "us"
}
}
});
if (resultConnect.Successful) {
// The call was connected, and is available at resultConnect.Call
}
Combine serial and parallel calling. Call +18991114443 first and - if it doesn't answer - try calling in parallel +18991114444 and +18991114445. If none of the devices answer, continue the same process with +18991114446 and +18991114447.
ConnectResult resultConnect = call.Connect(new List<List<CallDevice>>
{
new List<CallDevice>
{
new CallDevice
{
Type = CallDevice.DeviceType.phone,
Parameters = new CallDevice.PhoneParams
{
ToNumber = "+18991114443",
FromNumber = "+1YYYYYYYYYY",
Timeout = 30,
}
}
},
new List<CallDevice>
{
new CallDevice
{
Type = CallDevice.DeviceType.phone,
Parameters = new CallDevice.PhoneParams
{
ToNumber = "+18991114444",
FromNumber = "+1YYYYYYYYYY",
Timeout = 30,
}
},
new CallDevice
{
Type = CallDevice.DeviceType.phone,
Parameters = new CallDevice.PhoneParams
{
ToNumber = "+18991114445",
FromNumber = "+1YYYYYYYYYY",
Timeout = 20,
}
}
},
new List<CallDevice>
{
new CallDevice
{
Type = CallDevice.DeviceType.phone,
Parameters = new CallDevice.PhoneParams
{
ToNumber = "+18991114446",
FromNumber = "+1YYYYYYYYYY",
Timeout = 30,
}
},
new CallDevice
{
Type = CallDevice.DeviceType.phone,
Parameters = new CallDevice.PhoneParams
{
ToNumber = "+18991114447",
FromNumber = "+1YYYYYYYYYY",
Timeout = 20,
}
}
}
});
if (resultConnect.Successful) {
// The call was connected, and is available at resultConnect.Call
}
ConnectAsync​
Asynchronous version of Connect
. It does not wait the connect to complete or fail, but returns a ConnectAction
object you can interact with.
Parameters
See Connect
for the parameter list.
Returns
SignalWire.Relay.Calling.ConnectAction
- The action object to interact with.
Examples
Trying to connect a call by calling in series +18991114444 and +18991114445.
ConnectAction actionConnect = call.ConnectAsync(new List<List<CallDevice>>
{
new List<CallDevice>
{
new CallDevice
{
Type = CallDevice.DeviceType.phone,
Parameters = new CallDevice.PhoneParams
{
ToNumber = "+18991114444",
FromNumber = "+1YYYYYYYYYY",
Timeout = 30,
}
}
},
new List<CallDevice>
{
new CallDevice
{
Type = CallDevice.DeviceType.phone,
Parameters = new CallDevice.PhoneParams
{
ToNumber = "+18991114445",
FromNumber = "+1YYYYYYYYYY",
Timeout = 20,
}
}
}
});
// Do other stuff while the call is being connected
if (actionConnect.Completed && actionConnect.Result.Successful) {
// The call was connected, and is available at actionConnect.Result.Call
}
Detect​
Run a detector on the call and waits until the first detect update comes through. This is a general method for all types of detecting, see DetectAnsweringMachine
, DetectDigit
, or DetectFax
for more specific usage.
Parameters
Parameter | Type | Required | Description |
---|---|---|---|
detect | SignalWire.Relay.Calling.CallDetect | required | The configuration for detection. |
Returns
SignalWire.Relay.Calling.DetectResult
- The result object to interact with.
Examples
Start a detector and if successful, checks whether the
Type
is human from theSignalWire.Relay.Calling.DetectResult
object.
DetectResult resultDetect = call.Detect(
new CallDetect
{
Type = CallDetect.DetectType.machine,
Parameters = new CallDetect.MachineParams
{
}
});
if (resultDetect.Successful)
{
if (resultDetect.Type == DetectResultType.Human)
{
// ...
}
}
DetectAsync​
Asynchronous version of Detect
. It does not wait for the detection update but returns a SignalWire.Relay.Calling.DetectAction
object you can interact with. This is a general method for all types of detecting, see DetectAnsweringMachine
, DetectDigit
, or DetectFax
for more specific usage.
Parameters
See Detect
for the parameter list.
Returns
SignalWire.Relay.Calling.DetectAction
- The action object to interact with.
Examples
Start a detector and stop it after 5 seconds.
DetectAction actionDetect = call.DetectAsync(
new CallDetect
{
Type = CallDetect.DetectType.machine,
Parameters = new CallDetect.MachineParams
{
}
});
Thread.Sleep(5000);
actionDetect.Stop();
DetectAnsweringMachine​
This is a helper function that refines the use of Detect
. This simplifies detecting machines.
Parameters
Parameter | Type | Required | Description |
---|---|---|---|
initialTimeout | double | optional | The length of time in seconds to wait for the initial voice before giving up. Default to 4.5 . |
endSilenceTimeout | double | optional | The length of time in seconds to wait for the voice to finish. Default to 1.0 . |
machineVoiceThreshold | double | optional | The length of time in seconds for the voice to trigger a machine detection. Default to 1.25 . |
machineWordsThreshold | int | optional | The quantity of words to trigger a machine detection. Default to 6 . |
waitForBeep | bool? | optional | Indicates whether the detector should return immediately upon detecting a machine or if it should wait for the machine's beep to return. Default to false . |
Returns
SignalWire.Relay.Calling.DetectResult
- The result object to interact with.
Examples
Detect machine.
DetectResult resultDetect = call.DetectAnsweringMachine();
DetectAnsweringMachineAsync​
Asynchronous version of DetectAnsweringMachine
. It does not wait for the first detection update, but returns a SignalWire.Relay.Calling.DetectAction
object you can interact with.
Parameters
See DetectAnsweringMachine
for the parameter list.
Returns
SignalWire.Relay.Calling.DetectAction
- The action object to interact with.
Examples
Detect machine and stop after 5 seconds.
// within an asynchronous function ..
DetectAction actionDetect = call.DetectAnsweringMachineAsync();
Thread.Sleep(5000);
actionDetect.Stop();
DetectDigit​
This is a helper function that refines the use of Detect
. This simplifies detecting DTMF.
Parameters
Parameter | Type | Required | Description |
---|---|---|---|
digits | string | optional | The digits to detect. Default to 0123456789*# . |
Returns
SignalWire.Relay.Calling.DetectResult
- The result object to interact with.
Examples
Detect DTMF digits.
DetectResult resultDetect = call.DetectDigit();
DetectDigitAsync​
Asynchronous version of DetectDigit
. It does not wait for the first detection update, but returns a SignalWire.Relay.Calling.DetectAction
object you can interact with.
Parameters
See DetectDigit
for the parameter list.
Returns
SignalWire.Relay.Calling.DetectAction
- The action object to interact with.
Examples
Detect DTMF digits and stop after 5 seconds.
// within an asynchronous function ..
DetectAction actionDetect = call.DetectDigitAsync();
Thread.Sleep(5000);
actionDetect.Stop();
DetectFax​
This is a helper function that refines the use of Detect
. This simplifies detecting fax.
Parameters
Parameter | Type | Required | Description |
---|---|---|---|
tone | SignalWire.Relay.Calling.CallDetect.FaxParams.FaxTone ? | optional | The tone to detect. Default to CED . |
Returns
SignalWire.Relay.Calling.DetectResult
- The result object to interact with.
Examples
Detect fax.
DetectResult resultDetect = call.DetectFax();
DetectFaxAsync​
Asynchronous version of DetectFax
. It does not wait for the first detection update, but returns a SignalWire.Relay.Calling.DetectAction
object you can interact with.
Parameters
See DetectFax
for the parameter list.
Returns
SignalWire.Relay.Calling.DetectAction
- The action object to interact with.
Examples
Detect fax and stop after 5 seconds.
// within an asynchronous function ..
DetectAction actionDetect = call.DetectFaxAsync();
Thread.Sleep(5000);
actionDetect.Stop();
DetectHuman​
This is a helper function that refines the use of Detect
. This simplifies detecting humans.
Parameters
Parameter | Type | Required | Description |
---|---|---|---|
initialTimeout | double? | optional | The length of time in seconds to wait for the initial voice before giving up. Default to 4.5 . |
endSilenceTimeout | double? | optional | The length of time in seconds to wait for the voice to finish. Default to 1.0 . |
machineVoiceThreshold | double? | optional | The length of time in seconds for the voice to trigger a machine detection. Default to 1.25 . |
machineWordsThreshold | int? | optional | The quantity of words to trigger a machine detection. Default to 6 . |
Returns
SignalWire.Relay.Calling.DetectResult
- The result object to interact with.
Examples
Detect human.
DetectResult resultDetect = call.DetectHuman();
DetectHumanAsync​
Asynchronous version of DetectHuman
. It does not wait for the first detection update, but returns a SignalWire.Relay.Calling.DetectAction
object you can interact with.
Parameters
See DetectHuman
for the parameter list.
Returns
SignalWire.Relay.Calling.DetectAction
- The action object to interact with.
Examples
Detect human and stop after 5 seconds.
// within an asynchronous function ..
DetectAction actionDetect = call.DetectHumanAsync();
Thread.Sleep(5000);
actionDetect.Stop();
DetectMachine​
This is a helper function that refines the use of Detect
. This simplifies detecting machines.
Parameters
Parameter | Type | Required | Description |
---|---|---|---|
initialTimeout | double | optional | The length of time in seconds to wait for the initial voice before giving up. Default to 4.5 . |
endSilenceTimeout | double | optional | The length of time in seconds to wait for the voice to finish. Default to 1.0 . |
machineVoiceThreshold | double | optional | The length of time in seconds for the voice to trigger a machine detection. Default to 1.25 . |
machineWordsThreshold | int | optional | The quantity of words to trigger a machine detection. Default to 6 . |
Returns
SignalWire.Relay.Calling.DetectResult
- The result object to interact with.
Examples
Detect machine.
DetectResult resultDetect = call.DetectMachine();
DetectMachineAsync​
Asynchronous version of DetectMachine
. It does not wait for the first detection update, but returns a SignalWire.Relay.Calling.DetectAction
object you can interact with.
Parameters
See DetectMachine
for the parameter list.
Returns
SignalWire.Relay.Calling.DetectAction
- The action object to interact with.
Examples
Detect machine and stop after 5 seconds.
// within an asynchronous function ..
DetectAction actionDetect = call.DetectMachineAsync();
Thread.Sleep(5000);
actionDetect.Stop();
Dial​
This will start a call that was created with NewPhoneCall
(or another call creation method) and waits until the call has been answered or hung up.
Parameters
None
Returns
SignalWire.Relay.Calling.DialResult
- The result object to interact with.
Examples
PhoneCall call = client.Calling.NewPhoneCall("+1XXXXXXXXXX", "+1YYYYYYYYYY");
DialResult resultDial = call.Dial();
if (resultDial.Successful) {
// Call has been answered
}
FaxReceive​
Wait on a fax to come through the current call.
Parameters
None
Returns
SignalWire.Relay.Calling.FaxResult
- The result object to interact with.
Examples
Start receiving a fax and check whether it was successful.
FaxResult resultFax = call.FaxReceive();
if (resultFax.Successful)
{
// ...
}
FaxSendAsync​
Asynchronous version of FaxSend
. It does not wait for a fax but returns a SignalWire.Relay.Calling.FaxAction
object you can interact with.
Parameters
See FaxSend
for the parameter list.
Returns
SignalWire.Relay.Calling.FaxAction
- The action object to interact with.
Examples
Start listening for a fax and stop it after 5 seconds.
FaxAction actionFax = call.FaxSendAsync();
Thread.Sleep(5000);
actionFax.Stop();