Skip to main content

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

NameTypeDescription
IDstringThe unique identifier of the call.
TypestringThe type of call. Only phone is currently supported.
StateSignalWire.Relay.Calling.CallStateThe current state of the call.
PreviousStateSignalWire.Relay.Calling.CallStateThe previous state of the call.
ContextstringThe context the call belongs to.
PeerSignalWire.Relay.Calling.CallThe call your original call is connected to.
ActiveboolIndicates the call is active.
EndedboolIndicates the call has ended.
AnsweredboolIndicates the call has been answered.
BusyboolIndicates 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

ParameterTypeRequiredDescription
devicesList<List<SignalWire.Relay.Calling.CallDevice>>requiredA nested list of devices. Outer list is dialed in series, while inner list is called in parallel to each other.
ringbackList<SignalWire.Relay.Calling.CallMedia>optionalA 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

ParameterTypeRequiredDescription
detectSignalWire.Relay.Calling.CallDetectrequiredThe 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 the SignalWire.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

ParameterTypeRequiredDescription
initialTimeoutdoubleoptionalThe length of time in seconds to wait for the initial voice before giving up. Default to 4.5.
endSilenceTimeoutdoubleoptionalThe length of time in seconds to wait for the voice to finish. Default to 1.0.
machineVoiceThresholddoubleoptionalThe length of time in seconds for the voice to trigger a machine detection. Default to 1.25.
machineWordsThresholdintoptionalThe quantity of words to trigger a machine detection. Default to 6.
waitForBeepbool?optionalIndicates 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

ParameterTypeRequiredDescription
digitsstringoptionalThe 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

ParameterTypeRequiredDescription
toneSignalWire.Relay.Calling.CallDetect.FaxParams.FaxTone?optionalThe 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

ParameterTypeRequiredDescription
initialTimeoutdouble?optionalThe length of time in seconds to wait for the initial voice before giving up. Default to 4.5.
endSilenceTimeoutdouble?optionalThe length of time in seconds to wait for the voice to finish. Default to 1.0.
machineVoiceThresholddouble?optionalThe length of time in seconds for the voice to trigger a machine detection. Default to 1.25.
machineWordsThresholdint?optionalThe 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

ParameterTypeRequiredDescription
initialTimeoutdoubleoptionalThe length of time in seconds to wait for the initial voice before giving up. Default to 4.5.
endSilenceTimeoutdoubleoptionalThe length of time in seconds to wait for the voice to finish. Default to 1.0.
machineVoiceThresholddoubleoptionalThe length of time in seconds for the voice to trigger a machine detection. Default to 1.25.
machineWordsThresholdintoptionalThe 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();

FaxSend

Wait on a fax to send to a destination.

Parameters

ParameterTypeRequiredDescription
documentstringrequiredLocation of the document to send. PDF format only.
identitystringoptionalIdentity to display on receiving fax. Default is SignalWire DID.
headerInfostringoptionalCustom info to add to header of each fax page. The info, along with identity, date, and page number will be included in the header. Set to empty string to disable sending any header. Default is SignalWire.

Returns

SignalWire.Relay.Calling.FaxResult - The result object to interact with.

Examples

Send a fax and check whether it was successful.

FaxResult resultFax = call.FaxSend("https://cdn.signalwire.com/fax/dummy.pdf");

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 sending a fax and stop it after 5 seconds.

FaxAction actionFax = call.FaxSendAsync("https://cdn.signalwire.com/fax/dummy.pdf");

Thread.Sleep(5000);

actionFax.Stop();

Hangup

Hangup the call.

Parameters

SignalWire.Relay.Calling.DisconnectReason - The reason for the disconnect, defaulted to hangup.

Returns

SignalWire.Relay.Calling.HangupResult - The result object to interact with.

Examples

Hangup a call and check if it was successful.

HangupResult resultHangup = call.Hangup();
if (resultHangup.Successful) {
// Call has been disconnected with the default hangup reason
}

Play

Play one or more media to a Call and wait until the playing has ended. This is a general method for all types of playing, see PlayAudio, PlaySilence, PlayTTS, or PlayRingtone for more specific usage.

Parameters

ParameterTypeRequiredDescription
mediaList<SignalWire.Relay.Calling.CallMedia>requiredOne or more objects describing media to be played in order.
volumedouble?optionalControls the volume, between -40dB and +40dB where 0 is unchanged. Default is 0.

Returns

SignalWire.Relay.Calling.PlayResult - The result object to interact with.

Examples

Play multiple media elements in the call.

PlayResult resultPlay = call.Play(
new List<CallMedia>
{
new CallMedia
{
Type = CallMedia.MediaType.tts,
Parameters = new CallMedia.TTSParams
{
Text = "Listen to this awesome file!"
}
},
new CallMedia
{
Type = CallMedia.MediaType.audio,
Parameters = new CallMedia.AudioParams
{
URL = "https://cdn.signalwire.com/default-music/welcome.mp3"
}
},
new CallMedia
{
Type = CallMedia.MediaType.silence,
Parameters = new CallMedia.SilenceParams
{
Duration = 5
}
},
new CallMedia
{
Type = CallMedia.MediaType.ringtone,
Parameters = new CallMedia.RingtoneParams
{
Name = "us"
}
},
new CallMedia
{
Type = CallMedia.MediaType.tts,
Parameters = new CallMedia.TTSParams
{
Text = "Did you like it?"
}
}
},
volume: 4.0
);

PlayAsync

Asynchronous version of Play. It does not wait for theplaying to complete, but returns a [SignalWire.Relay.Calling.PlayAction`]signalwire-relay-calling-playaction-9 object you can interact with.

Parameters

See Play for the parameter list.

Returns

SignalWire.Relay.Calling.PlayAction - The action object to interact with.

Examples

Play multiple media elements in the call and stop them after 5 seconds.

PlayAction actionPlay = call.PlayAsync(
new List<CallMedia>
{
new CallMedia
{
Type = CallMedia.MediaType.tts,
Parameters = new CallMedia.TTSParams
{
Text = "Listen to this awesome file!"
}
},
new CallMedia
{
Type = CallMedia.MediaType.audio,
Parameters = new CallMedia.AudioParams
{
URL = "https://cdn.signalwire.com/default-music/welcome.mp3"
}
},
new CallMedia
{
Type = CallMedia.MediaType.silence,
Parameters = new CallMedia.SilenceParams
{
Duration = 5
}
},
new CallMedia
{
Type = CallMedia.MediaType.ringtone,
Parameters = new CallMedia.RingtoneParams
{
Name = "us"
}
},
new CallMedia
{
Type = CallMedia.MediaType.tts,
Parameters = new CallMedia.TTSParams
{
Text = "Did you like it?"
}
}
},
volume: 4.0
);

Thread.Sleep(5000);

actionPlay.Stop();

PlayAudio

This is a helper function that refines the use of Play. This simplifies playing an audio file.

Parameters

ParameterTypeRequiredDescription
urlstringrequiredHttp(s) URL to audio resource to play.
volumedouble?optionalControls the volume, between -40dB and +40dB where 0 is unchanged. Default is 0.

Returns

SignalWire.Relay.Calling.PlayResult - The result object to interact with.

Examples

Play an MP3 file.

PlayResult resultPlay = call.PlayAudio("https://cdn.signalwire.com/default-music/welcome.mp3", volume: 4.0);

PlayAudioAsync

Asynchronous version of PlayAudio. It does not wait for the playing to complete, but returns a SignalWire.Relay.Calling.PlayAction object you can interact with.

Parameters

See PlayAudio for the parameter list.

Returns

SignalWire.Relay.Calling.PlayAction - The action object to interact with.

Examples

Play an MP3 file and stop it after 5 seconds.

// within an asynchronous function ..
PlayAction actionPlay = call.PlayAudioAsync("https://cdn.signalwire.com/default-music/welcome.mp3", volume: 4.0);

Thread.Sleep(5000);

actionPlay.Stop();

PlayRingtone

This is a helper function that refines the use of Play. This simplifies playing ringtones.

Parameters

ParameterTypeRequiredDescription
namestringrequiredThe name of the ringtone, see SignalWire.Relay.Calling.CallMedia.RingtoneParams.
durationdouble?optionalDefault to null, 1 ringtone iteration.
volumedouble?optionalControls the volume, between -40dB and +40dB where 0 is unchanged. Default is 0.

Returns

SignalWire.Relay.Calling.PlayResult - The result object to interact with.

Examples

Play a single US ringtone.

PlayResult resultPlay = call.PlayRingtone("us");

PlayRingtoneAsync

Asynchronous version of PlayRingtone. It does not wait for the playing to complete, but returns a SignalWire.Relay.Calling.PlayAction object you can interact with.

Parameters

See PlayRingtone for the parameter list.

Returns

SignalWire.Relay.Calling.PlayAction - The action object to interact with.

Examples

Play US ringtone for 60 seconds, if Agent is available, stop the play.

PlayAction actionPlay = call.PlayRingtoneAsync("us", duration: 60);

if (agent.Available()) {
actionPlay.Stop();
}

PlaySilence

This is a helper function that refines the use of Play. This simplifies playing silence.

Parameters

ParameterTypeRequiredDescription
durationdoublerequiredSeconds of silence to play.

Returns

SignalWire.Relay.Calling.PlayResult - The result object to interact with.

Examples

Play silence for 10 seconds.

PlayResult resultPlay = call.PlaySilence(10);

PlaySilenceAsync

Asynchronous version of PlaySilence. It does not wait for the playing to complete, but returns a SignalWire.Relay.Calling.PlayAction object you can interact with.

Parameters

See PlaySilence for the parameter list.

Returns

SignalWire.Relay.Calling.PlayAction - The action object to interact with.

Examples

Play silence for 60 seconds, if Agent is available, stop the play.

PlayAction actionPlay = call.PlaySilenceAsync(60);

if (agent.Available()) {
actionPlay.Stop();
}

PlayTTS

This is a helper function that refines the use of Play. This simplifies playing TTS.

Parameters

ParameterTypeRequiredDescription
textstringrequiredThe text to speak.
genderstringoptionalmale or female. Default to female.
languagestringoptionalDefault to en-US.
volumedouble?optionalControls the volume, between -40dB and +40dB where 0 is unchanged. Default is 0.

Returns

SignalWire.Relay.Calling.PlayResult - The result object to interact with.

Examples

Play TTS.

PlayResult resultPlay = call.PlayTTS("Welcome to SignalWire!", gender: "male", volume: 4.0 });

PlayTTSAsync

Asynchronous version of PlayTTS. It does not wait for the playing to complete, but returns a SignalWire.Relay.Calling.PlayAction object you can interact with.

Parameters

See PlayTTS for the parameter list.

Returns

SignalWire.Relay.Calling.PlayAction - The action object to interact with.

Examples

Play TTS and stop it after 3 seconds.

PlayAction actionPlay = call.PlayTTSAsync("Welcome to SignalWire! Making communications easy for everyone!", gender: "male", volume: 4.0 })

Thread.Sleep(3000);

actionPlay.Stop();

Prompt

Play one or more media while collecting user's input from the call at the same time, such as digits and speech.
It waits until the collection succeed or timeout is reached. This is a general method for all types of playing, see PromptAudio or PromptTTS for more specific usage.

Parameters

ParameterTypeRequiredDescription
mediaList<SignalWire.Relay.Calling.CallMedia>requiredOne or more objects describing media to be played in order.
collectSignalWire.Relay.Calling.CallCollectrequiredThe configuration for input collection.
volumedouble?optionalControls the volume, between -40dB and +40dB where 0 is unchanged. Default is 0.

Returns

SignalWire.Relay.Calling.PromptResult - The result object to interact with.

Examples

Ask user to enter their PIN and collect the digits.

PromptResult resultPrompt = call.Prompt(
new List<CallMedia>
{
new CallMedia
{
Type = CallMedia.MediaType.tts,
Parameters = new CallMedia.TTSParams
{
Text = "Welcome to SignalWire! Please enter your PIN",
}
}
},
new CallCollect
{
InitialTimeout = 10,
Digits = new CallCollect.DigitsParams
{
Max = 4,
DigitTimeout = 5,
}
},
volume: 4.0);

if (resultPrompt.Successful)
{
// The collected input is in resultPrompt.Result
}

PromptAsync

Asynchronous version of Prompt. It does not wait for the collect to complete, but returns a SignalWire.Relay.Calling.PromptAction object you can interact with.

Parameters

See Prompt for the parameter list.

Returns

SignalWire.Relay.Calling.PromptAction - The action object to interact with.

Examples

Ask user to enter their PIN and collect the digits.

PromptAction actionPrompt = call.PromptAsync(
new List<CallMedia>
{
new CallMedia
{
Type = CallMedia.MediaType.tts,
Parameters = new CallMedia.TTSParams
{
Text = "Welcome to SignalWire! Please enter your PIN",
}
},
new CallMedia
{
Type = CallMedia.MediaType.audio,
Parameters = new CallMedia.AudioParams
{
URL = "https://cdn.signalwire.com/default-music/welcome.mp3",
}
}
},
new CallCollect
{
InitialTimeout = 10,
Digits = new CallCollect.DigitsParams
{
Max = 4,
DigitTimeout = 5,
}
},
volume: 4.0);

// Do other stuff

if (actionPrompt.Completed)
{
if (actionPrompt.Result.Successful)
{
// The collected input is in actionPrompt.Result.Result
}
}

PromptAudio

This is a helper function that refines the use of Prompt.
This function simplifies playing an audio file while collecting user input from the call, such as digits and speech.

Parameters

ParameterTypeRequiredDescription
urlstringrequiredHttp(s) URL to audio resource to play.
collectSignalWire.Relay.Calling.CallCollectrequiredThe configuration for input collection.
volumedouble?optionalControls the volume, between -40dB and +40dB where 0 is unchanged. Default is 0.

Returns

SignalWire.Relay.Calling.PromptResult - The result object to interact with.

Examples

Collect user digits while playing an MP3 file.

PromptResult resultPrompt = call.PromptAudio(
"https://cdn.signalwire.com/default-music/welcome.mp3",
new CallCollect
{
InitialTimeout = 10,
Digits = new CallCollect.DigitsParams
{
Max = 4,
DigitTimeout = 5,
}
},
volume: 4.0);

if (resultPrompt.Successful)
{
// The collected input is in resultPrompt.Result
}

PromptAudioAsync

Asynchronous version of PromptAudio. It does not wait for the collection to complete, but returns a SignalWire.Relay.Calling.PromptAction object you can interact with.

Parameters

See PromptAudio for the parameter list.

Returns

SignalWire.Relay.Calling.PromptAction - The action object to interact with.

Examples

Collect user digits while playing an MP3 file.

PromptAction actionPrompt = call.PromptAudioAsync(
"https://cdn.signalwire.com/default-music/welcome.mp3",
new CallCollect
{
InitialTimeout = 10,
Digits = new CallCollect.DigitsParams
{
Max = 4,
DigitTimeout = 5,
}
},
volume: 4.0);

if (actionPrompt.Completed)
{
if (actionPrompt.Result.Successful)
{
// The collected input is in actionPrompt.Result.Result
}
}

PromptRingtone

This is a helper function that refines the use of Prompt.
This function simplifies playing ringtones while collecting user input from the call, such as digits and speech.

Parameters

ParameterTypeRequiredDescription
namestringrequiredThe name of the ringtone, see SignalWire.Relay.Calling.CallMedia.RingtoneParams.
collectSignalWire.Relay.Calling.CallCollectrequiredThe configuration for input collection.
durationdouble?optionalDefault to null, 1 ringtone iteration.
volumedouble?optionalControls the volume, between -40dB and +40dB where 0 is unchanged. Default is 0.

Returns

SignalWire.Relay.Calling.PromptResult - The result object to interact with.

Examples

Play a US ringtone once and collect digits.

PromptResult resultPrompt = call.PromptRingtone(
"us",
new CallCollect
{
InitialTimeout = 10,
Digits = new CallCollect.DigitsParams
{
Max = 4,
DigitTimeout = 5,
}
},
volume: 4.0);

if (resultPrompt.Successful)
{
// The collected input is in resultPrompt.Result
}

PromptRingtoneAsync

Asynchronous version of PromptRingtone. It does not wait for the collection to complete, but returns a SignalWire.Relay.Calling.PromptAction object you can interact with.

Parameters

See PromptRingtone for the parameter list.

Returns

SignalWire.Relay.Calling.PromptAction - The action object to interact with.

Examples

Play a US ringtone once and collect digits.

PromptAction actionPrompt = call.PromptRingtoneAsync(
"us",
new CallCollect
{
InitialTimeout = 10,
Digits = new CallCollect.DigitsParams
{
Max = 4,
DigitTimeout = 5,
}
},
volume: 4.0);

if (actionPrompt.Completed)
{
if (actionPrompt.Result.Successful)
{
// The collected input is in actionPrompt.Result.Result
}
}

PromptTTS

This is a helper function that refines the use of Prompt.
This function simplifies playing TTS while collecting user input from the call, such as digits and speech.

Parameters

ParameterTypeRequiredDescription
textstringrequiredThe text to speak.
collectSignalWire.Relay.Calling.CallCollectrequiredThe configuration for input collection.
genderstringoptionalmale or female. Default to female.
languagestringoptionalDefault to en-US.
volumedouble?optionalControls the volume, between -40dB and +40dB where 0 is unchanged. Default is 0.

Returns

SignalWire.Relay.Calling.PromptResult - The result object to interact with.

Examples

Ask user to enter their PIN and collect the digits.

PromptResult resultPrompt = call.PromptTTS(
"Welcome to SignalWire! Please enter your PIN",
new CallCollect
{
InitialTimeout = 10,
Digits = new CallCollect.DigitsParams
{
Max = 4,
DigitTimeout = 5,
}
},
gender: "male",
volume: 4.0);

if (resultPrompt.Successful)
{
// The collected input is in resultPrompt.Result
}

PromptTTSAsync

Asynchronous version of PromptTTS. It does not wait for the collection to complete, but returns a SignalWire.Relay.Calling.PromptAction object you can interact with.

Parameters

See PromptTTS for the parameter list.

Returns

SignalWire.Relay.Calling.PromptAction - The action object to interact with.

Examples

Ask user to enter their PIN and collect the digits.

PromptAction actionPrompt = call.PromptTTSAsync(
"Welcome to SignalWire! Please enter your PIN",
new CallCollect
{
InitialTimeout = 10,
Digits = new CallCollect.DigitsParams
{
Max = 4,
DigitTimeout = 5,
}
},
gender: "male",
volume: 4.0);

if (actionPrompt.Completed)
{
if (actionPrompt.Result.Successful)
{
// The collected input is in actionPrompt.Result.Result
}
}

Record

Start recording the call and waits until the recording ends or fails.

Parameters

ParameterTypeRequiredDescription
recordSignalWire.Relay.Calling.CallRecordrequiredThe configuration for recording.

Returns

SignalWire.Relay.Calling.RecordResult - The result object to interact with.

Examples

Start recording audio in the call for both direction in stereo mode, if successful, grab Url, Duration and Size from the SignalWire.Relay.Calling.RecordResult object.

RecordResult resultRecord = call.Record(
new CallRecord
{
Audio = new CallRecord.AudioParams
{
Stereo = true,
Direction = CallRecord.AudioParams.AudioDirection.both,
}
});

if (resultRecord.Successful)
{
// The URL for the recording is available in resultRecord.Url
}

RecordAsync

Asynchronous version of Record. It does not wait for the end of the recording but returns a SignalWire.Relay.Calling.RecordAction object you can interact with.

Parameters

See Record for the parameter list.

Returns

SignalWire.Relay.Calling.RecordAction - The action object to interact with.

Examples

Start recording audio in the call for both direction in stereo mode and stop it after 5 seconds.

RecordAction actionRecord = call.RecordAsync(
new CallRecord
{
Audio = new CallRecord.AudioParams
{
Stereo = true,
Direction = CallRecord.AudioParams.AudioDirection.both,
}
});

Thread.Sleep(5000);

actionRecord.Stop();

SendDigits

Sends DTMF digits to the other party on the call.

Parameters

ParameterTypeRequiredDescription
digitsstringrequiredThe digits to send. Allowed digits are 1234567890*#ABCD. w and W may be used to indicate short and long waits respectively. If any invalid characters are present, the entire operation is rejected.

Returns

SignalWire.Relay.Calling.SendDigitsResult - The result object to interact with.

Examples

Send digits and check whether sending was successful.

SendDigitsResult result = call.SendDigits("123w456W789");

if (result.Successful)
{
// ...
}

SendDigitsAsync

Asynchronous version of SendDigits. It does not wait for all digits to be sent but returns a SignalWire.Relay.Calling.SendDigitsAction object you can interact with.

Parameters

See SendDigits for the parameter list.

Returns

SignalWire.Relay.Calling.SendDigitsAction - The action object to interact with.

Examples

Start sending digits.

SendDigitsAction action = call.SendDigits("123w456W789");

// Do other things

Tap

Start tapping the call and waits until the tap ends or fails.

Parameters

ParameterTypeRequiredDescription
tapSignalWire.Relay.Calling.CallTaprequiredThe configuration for tapping.
deviceSignalWire.Relay.Calling.CallTapDevicerequiredThe configuration for the target device.

Returns

SignalWire.Relay.Calling.TapResult - The result object to interact with.

Examples

Start tapping audio in the call for both directions.

TapResult resultTap = call.Tap(
new CallTap
{
Audio = new CallTap.AudioParams
{
Direction = CallTap.AudioParams.AudioDirection.both,
}
},
new CallTapDevice
{
Type = CallTapDevice.DeviceType.rtp,
Parameters = new CallTapDevice.RTPParams
{
Address = "1.2.3.4",
Port = 12345,
}
});

if (resultTap.Successful)
{
// The RTP data is flowing to the device
}

TapAsync

Asynchronous version of Tap. It does not wait for the end of the tapping but returns a TapAction object you can interact with.

Parameters

See Tap for the parameter list.

Returns

SignalWire.Relay.Calling.TapAction - The action object to interact with.

Examples

Start tapping audio in the call for both directions and stop it after 5 seconds.

TapAction actionTap = call.TapAsync(
new CallTap
{
Audio = new CallTap.AudioParams
{
Direction = CallTap.AudioParams.AudioDirection.both,
}
},
new CallTapDevice
{
Type = CallTapDevice.DeviceType.rtp,
Parameters = new CallTapDevice.RTPParams
{
Address = "1.2.3.4",
Port = 12345,
}
});

Thread.Sleep(5000);

actionTap.Stop();

WaitFor

Block until the current state of the call is one of the specified SignalWire.Relay.Calling.CallState values. This is a general method, see WaitForAnswered, WaitForEnded, WaitForEnding, or WaitForRinging for more specific usage.

Parameters

ParameterTypeRequiredDescription
timeoutTimeSpan?requiredThe maximum amount of time to wait. null is interpreted as an infinite wait.
statesparams SignalWire.Relay.Calling.CallStaterequiredThe states to wait for.

Returns

bool - Will have the value true if the state is consistent with one of the provided states or false if a timeout occurred.

Examples

Wait to see if a call is answered

bool stateValid = call.WaitFor(null, CallState.answered);
if (stateValid) {
// The call is answered
}

WaitForAnswered

This is a helper function that refines the use of WaitFor. Block until the current state of the call is the answered SignalWire.Relay.Calling.CallState.

Parameters

ParameterTypeRequiredDescription
timeoutTimeSpan?optionalThe maximum amount of time to wait. null is interpreted as an infinite wait. Default to null.

Returns

bool - Will have the value true if the state is consistent with the specified SignalWire.Relay.Calling.CallState or false if a timeout occurred.

Examples

Wait to see if a call is answered

bool stateValid = call.WaitForAnswered();
if (stateValid) {
// The call is answered
}

WaitForEnded

This is a helper function that refines the use of WaitFor. Block until the current state of the call is the ended SignalWire.Relay.Calling.CallState.

Parameters

ParameterTypeRequiredDescription
timeoutTimeSpan?optionalThe maximum amount of time to wait. null is interpreted as an infinite wait. Default to null.

Returns

bool - Will have the value true if the state is consistent with the specified SignalWire.Relay.Calling.CallState or false if a timeout occurred.

Examples

Wait to see if a call is ended

bool stateValid = call.WaitForEnded();
if (stateValid) {
// The call is ended
}

WaitForEnding

This is a helper function that refines the use of WaitFor. Block until the current state of the call is the ending SignalWire.Relay.Calling.CallState.

Parameters

ParameterTypeRequiredDescription
timeoutTimeSpan?optionalThe maximum amount of time to wait. null is interpreted as an infinite wait. Default to null.

Returns

bool - Will have the value true if the state is consistent with the specified SignalWire.Relay.Calling.CallState or false if a timeout occurred.

Examples

Wait to see if a call is ending

bool stateValid = call.WaitForEnding();
if (stateValid) {
// The call is ending
}

WaitForRinging

This is a helper function that refines the use of WaitFor. Block until the current state of the call is the ringing SignalWire.Relay.Calling.CallState.

Parameters

ParameterTypeRequiredDescription
timeoutTimeSpan?optionalThe maximum amount of time to wait. null is interpreted as an infinite wait. Default to null.

Returns

bool - Will have the value true if the state is consistent with the specified SignalWire.Relay.Calling.CallState or false if a timeout occurred.

Examples

Wait to see if a call is ringing

bool stateValid = call.WaitForRinging();
if (stateValid) {
// The call is ringing
}

Events

All these events can be used to track the calls lifecycle and instruct SignalWire on what to do for each different state.

State Events

To track the state of a call.

| Name | Type | Description | | -: | - | | OnStateChange | The call is changing state, generalized event for the following events. | | OnRinging | The call is ringing and has not yet been answered. | | OnAnswered | The call has been picked up. | | OnEnding | The call is hanging up. | | OnEnded | The call has ended. |

Connect Events

To track the connect state of a call.

| Name | Type | Description | | -: | - | | OnConnectStateChange | The connect state is changing, generalized event for the following events. | | OnConnectFailed | The last call connection attempt failed. | | OnConnectConnecting | Currently calling the phone number(s) to connect. | | OnConnectConnected | The calls are being connected together. | | OnConnectDisconnected | The call was either never connected or the last call connection completed. |

Detect Events

To track a detection.

| Name | Type | Description | | -: | - | | OnDetectError | The detection failed. | | OnDetectFinished | The detection has finished. | | OnDetectUpdate | The detection state is changing, generalized event for the following events. |

Fax Events

To track a fax operation.

| Name | Type | Description | | -: | - | | OnFaxError | The fax operation failed. | | OnFaxFinished | The fax operation finished. | | OnFaxPage | The fax operation sent a page. |

Play Events

To track a playback state.

| Name | Type | Description | | -: | - | | OnPlayStateChange | The play state is changing, generalized event for the following events. | | OnPlayPlaying | One of the medias are being played to the call. | | OnPlayError | The play of media failed. | | OnPlayFinished | The playing of media has finished. |

Prompt Events

To track a prompt state.

| Name | Type | Description | | -: | - | | OnPrompt | The prompt action on the call has ended. |

Record Events

To track a recording state.

| Name | Type | Description | | -: | - | | OnRecordStateChange | The record state is changing, generalized event for the following events. | | OnRecordRecording | The call is being recorded. | | OnRecordFinished | The recording has finished. | | OnRecordNoInput | The recording failed due to no input detected. |

Send Digits Events

To receive a message when the digits are finished sending.

| Name | Type | Description | | -: | - | | OnSendDigitsStateChange | The send digits state is changing, generalized event for the following events. | | OnSendDigitsFinished | The digits have finished sending. |

Tap Events

To track an active tap.

NameDescription
OnTapStateChangeThe tap state is changing, generalized event for the following events.
OnTapTappingThe call is being tapped.
OnTapFinishedThe tapping has finished.