SignalWire.Relay.Calling.Call

View as Markdown

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.

1AnswerResult resultAnswer = call.Answer();
2if (resultAnswer.Successful) {
3 // The call has been answered
4}

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.

1ConnectResult resultConnect = call.Connect(new List<List<CallDevice>>
2{
3 new List<CallDevice>
4 {
5 new CallDevice
6 {
7 Type = CallDevice.DeviceType.phone,
8 Parameters = new CallDevice.PhoneParams
9 {
10 ToNumber = "+18991114444",
11 FromNumber = "+1YYYYYYYYYY",
12 Timeout = 30,
13 }
14 }
15 },
16 new List<CallDevice>
17 {
18 new CallDevice
19 {
20 Type = CallDevice.DeviceType.phone,
21 Parameters = new CallDevice.PhoneParams
22 {
23 ToNumber = "+18991114445",
24 FromNumber = "+1YYYYYYYYYY",
25 Timeout = 20,
26 }
27 }
28 }
29},
30ringback: new List<CallMedia>
31{
32 new CallMedia
33 {
34 Type = CallMedia.MediaType.ringtone,
35 Parameters = new CallMedia.RingtoneParams
36 {
37 Name = "us"
38 }
39 }
40});
41
42if (resultConnect.Successful) {
43 // The call was connected, and is available at resultConnect.Call
44}

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.

1ConnectResult resultConnect = call.Connect(new List<List<CallDevice>>
2{
3 new List<CallDevice>
4 {
5 new CallDevice
6 {
7 Type = CallDevice.DeviceType.phone,
8 Parameters = new CallDevice.PhoneParams
9 {
10 ToNumber = "+18991114443",
11 FromNumber = "+1YYYYYYYYYY",
12 Timeout = 30,
13 }
14 }
15 },
16 new List<CallDevice>
17 {
18 new CallDevice
19 {
20 Type = CallDevice.DeviceType.phone,
21 Parameters = new CallDevice.PhoneParams
22 {
23 ToNumber = "+18991114444",
24 FromNumber = "+1YYYYYYYYYY",
25 Timeout = 30,
26 }
27 },
28 new CallDevice
29 {
30 Type = CallDevice.DeviceType.phone,
31 Parameters = new CallDevice.PhoneParams
32 {
33 ToNumber = "+18991114445",
34 FromNumber = "+1YYYYYYYYYY",
35 Timeout = 20,
36 }
37 }
38 },
39 new List<CallDevice>
40 {
41 new CallDevice
42 {
43 Type = CallDevice.DeviceType.phone,
44 Parameters = new CallDevice.PhoneParams
45 {
46 ToNumber = "+18991114446",
47 FromNumber = "+1YYYYYYYYYY",
48 Timeout = 30,
49 }
50 },
51 new CallDevice
52 {
53 Type = CallDevice.DeviceType.phone,
54 Parameters = new CallDevice.PhoneParams
55 {
56 ToNumber = "+18991114447",
57 FromNumber = "+1YYYYYYYYYY",
58 Timeout = 20,
59 }
60 }
61 }
62});
63
64if (resultConnect.Successful) {
65 // The call was connected, and is available at resultConnect.Call
66}

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.

1ConnectAction actionConnect = call.ConnectAsync(new List<List<CallDevice>>
2{
3 new List<CallDevice>
4 {
5 new CallDevice
6 {
7 Type = CallDevice.DeviceType.phone,
8 Parameters = new CallDevice.PhoneParams
9 {
10 ToNumber = "+18991114444",
11 FromNumber = "+1YYYYYYYYYY",
12 Timeout = 30,
13 }
14 }
15 },
16 new List<CallDevice>
17 {
18 new CallDevice
19 {
20 Type = CallDevice.DeviceType.phone,
21 Parameters = new CallDevice.PhoneParams
22 {
23 ToNumber = "+18991114445",
24 FromNumber = "+1YYYYYYYYYY",
25 Timeout = 20,
26 }
27 }
28 }
29});
30
31// Do other stuff while the call is being connected
32
33if (actionConnect.Completed && actionConnect.Result.Successful) {
34 // The call was connected, and is available at actionConnect.Result.Call
35}

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.

1DetectResult resultDetect = call.Detect(
2 new CallDetect
3 {
4 Type = CallDetect.DetectType.machine,
5 Parameters = new CallDetect.MachineParams
6 {
7 }
8 });
9
10if (resultDetect.Successful)
11{
12 if (resultDetect.Type == DetectResultType.Human)
13 {
14 // ...
15 }
16}

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.

1DetectAction actionDetect = call.DetectAsync(
2 new CallDetect
3 {
4 Type = CallDetect.DetectType.machine,
5 Parameters = new CallDetect.MachineParams
6 {
7 }
8 });
9
10Thread.Sleep(5000);
11
12actionDetect.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.

1DetectResult 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.

1// within an asynchronous function ..
2DetectAction actionDetect = call.DetectAnsweringMachineAsync();
3
4Thread.Sleep(5000);
5
6actionDetect.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.

1DetectResult 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.

1// within an asynchronous function ..
2DetectAction actionDetect = call.DetectDigitAsync();
3
4Thread.Sleep(5000);
5
6actionDetect.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.

1DetectResult 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.

1// within an asynchronous function ..
2DetectAction actionDetect = call.DetectFaxAsync();
3
4Thread.Sleep(5000);
5
6actionDetect.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.

1DetectResult 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.

1// within an asynchronous function ..
2DetectAction actionDetect = call.DetectHumanAsync();
3
4Thread.Sleep(5000);
5
6actionDetect.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.

1DetectResult 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.

1// within an asynchronous function ..
2DetectAction actionDetect = call.DetectMachineAsync();
3
4Thread.Sleep(5000);
5
6actionDetect.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

1PhoneCall call = client.Calling.NewPhoneCall("+1XXXXXXXXXX", "+1YYYYYYYYYY");
2DialResult resultDial = call.Dial();
3if (resultDial.Successful) {
4 // Call has been answered
5}

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.

1FaxResult resultFax = call.FaxReceive();
2
3if (resultFax.Successful)
4{
5 // ...
6}

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.

1FaxAction actionFax = call.FaxSendAsync();
2
3Thread.Sleep(5000);
4
5actionFax.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.

1FaxResult resultFax = call.FaxSend("https://cdn.signalwire.com/fax/dummy.pdf");
2
3if (resultFax.Successful)
4{
5 // ...
6}

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.

1FaxAction actionFax = call.FaxSendAsync("https://cdn.signalwire.com/fax/dummy.pdf");
2
3Thread.Sleep(5000);
4
5actionFax.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.

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

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.

1PlayResult resultPlay = call.Play(
2 new List<CallMedia>
3 {
4 new CallMedia
5 {
6 Type = CallMedia.MediaType.tts,
7 Parameters = new CallMedia.TTSParams
8 {
9 Text = "Listen to this awesome file!"
10 }
11 },
12 new CallMedia
13 {
14 Type = CallMedia.MediaType.audio,
15 Parameters = new CallMedia.AudioParams
16 {
17 URL = "https://cdn.signalwire.com/default-music/welcome.mp3"
18 }
19 },
20 new CallMedia
21 {
22 Type = CallMedia.MediaType.silence,
23 Parameters = new CallMedia.SilenceParams
24 {
25 Duration = 5
26 }
27 },
28 new CallMedia
29 {
30 Type = CallMedia.MediaType.ringtone,
31 Parameters = new CallMedia.RingtoneParams
32 {
33 Name = "us"
34 }
35 },
36 new CallMedia
37 {
38 Type = CallMedia.MediaType.tts,
39 Parameters = new CallMedia.TTSParams
40 {
41 Text = "Did you like it?"
42 }
43 }
44 },
45 volume: 4.0
46);

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.

1PlayAction actionPlay = call.PlayAsync(
2 new List<CallMedia>
3 {
4 new CallMedia
5 {
6 Type = CallMedia.MediaType.tts,
7 Parameters = new CallMedia.TTSParams
8 {
9 Text = "Listen to this awesome file!"
10 }
11 },
12 new CallMedia
13 {
14 Type = CallMedia.MediaType.audio,
15 Parameters = new CallMedia.AudioParams
16 {
17 URL = "https://cdn.signalwire.com/default-music/welcome.mp3"
18 }
19 },
20 new CallMedia
21 {
22 Type = CallMedia.MediaType.silence,
23 Parameters = new CallMedia.SilenceParams
24 {
25 Duration = 5
26 }
27 },
28 new CallMedia
29 {
30 Type = CallMedia.MediaType.ringtone,
31 Parameters = new CallMedia.RingtoneParams
32 {
33 Name = "us"
34 }
35 },
36 new CallMedia
37 {
38 Type = CallMedia.MediaType.tts,
39 Parameters = new CallMedia.TTSParams
40 {
41 Text = "Did you like it?"
42 }
43 }
44 },
45 volume: 4.0
46);
47
48Thread.Sleep(5000);
49
50actionPlay.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.

1PlayResult 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.

1// within an asynchronous function ..
2PlayAction actionPlay = call.PlayAudioAsync("https://cdn.signalwire.com/default-music/welcome.mp3", volume: 4.0);
3
4Thread.Sleep(5000);
5
6actionPlay.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.

1PlayResult 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.

1PlayAction actionPlay = call.PlayRingtoneAsync("us", duration: 60);
2
3if (agent.Available()) {
4 actionPlay.Stop();
5}

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.

1PlayResult 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.

1PlayAction actionPlay = call.PlaySilenceAsync(60);
2
3if (agent.Available()) {
4 actionPlay.Stop();
5}

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.

1PlayResult 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.

1PlayAction actionPlay = call.PlayTTSAsync("Welcome to SignalWire! Making communications easy for everyone!", gender: "male", volume: 4.0 })
2
3Thread.Sleep(3000);
4
5actionPlay.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.

1PromptResult resultPrompt = call.Prompt(
2 new List<CallMedia>
3 {
4 new CallMedia
5 {
6 Type = CallMedia.MediaType.tts,
7 Parameters = new CallMedia.TTSParams
8 {
9 Text = "Welcome to SignalWire! Please enter your PIN",
10 }
11 }
12 },
13 new CallCollect
14 {
15 InitialTimeout = 10,
16 Digits = new CallCollect.DigitsParams
17 {
18 Max = 4,
19 DigitTimeout = 5,
20 }
21 },
22 volume: 4.0);
23
24if (resultPrompt.Successful)
25{
26 // The collected input is in resultPrompt.Result
27}

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.

1PromptAction actionPrompt = call.PromptAsync(
2 new List<CallMedia>
3 {
4 new CallMedia
5 {
6 Type = CallMedia.MediaType.tts,
7 Parameters = new CallMedia.TTSParams
8 {
9 Text = "Welcome to SignalWire! Please enter your PIN",
10 }
11 },
12 new CallMedia
13 {
14 Type = CallMedia.MediaType.audio,
15 Parameters = new CallMedia.AudioParams
16 {
17 URL = "https://cdn.signalwire.com/default-music/welcome.mp3",
18 }
19 }
20 },
21 new CallCollect
22 {
23 InitialTimeout = 10,
24 Digits = new CallCollect.DigitsParams
25 {
26 Max = 4,
27 DigitTimeout = 5,
28 }
29 },
30 volume: 4.0);
31
32// Do other stuff
33
34if (actionPrompt.Completed)
35{
36 if (actionPrompt.Result.Successful)
37 {
38 // The collected input is in actionPrompt.Result.Result
39 }
40}

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.

1PromptResult resultPrompt = call.PromptAudio(
2 "https://cdn.signalwire.com/default-music/welcome.mp3",
3 new CallCollect
4 {
5 InitialTimeout = 10,
6 Digits = new CallCollect.DigitsParams
7 {
8 Max = 4,
9 DigitTimeout = 5,
10 }
11 },
12 volume: 4.0);
13
14if (resultPrompt.Successful)
15{
16 // The collected input is in resultPrompt.Result
17}

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.

1PromptAction actionPrompt = call.PromptAudioAsync(
2 "https://cdn.signalwire.com/default-music/welcome.mp3",
3 new CallCollect
4 {
5 InitialTimeout = 10,
6 Digits = new CallCollect.DigitsParams
7 {
8 Max = 4,
9 DigitTimeout = 5,
10 }
11 },
12 volume: 4.0);
13
14if (actionPrompt.Completed)
15{
16 if (actionPrompt.Result.Successful)
17 {
18 // The collected input is in actionPrompt.Result.Result
19 }
20}

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.

1PromptResult resultPrompt = call.PromptRingtone(
2 "us",
3 new CallCollect
4 {
5 InitialTimeout = 10,
6 Digits = new CallCollect.DigitsParams
7 {
8 Max = 4,
9 DigitTimeout = 5,
10 }
11 },
12 volume: 4.0);
13
14if (resultPrompt.Successful)
15{
16 // The collected input is in resultPrompt.Result
17}

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.

1PromptAction actionPrompt = call.PromptRingtoneAsync(
2 "us",
3 new CallCollect
4 {
5 InitialTimeout = 10,
6 Digits = new CallCollect.DigitsParams
7 {
8 Max = 4,
9 DigitTimeout = 5,
10 }
11 },
12 volume: 4.0);
13
14if (actionPrompt.Completed)
15{
16 if (actionPrompt.Result.Successful)
17 {
18 // The collected input is in actionPrompt.Result.Result
19 }
20}

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.

1PromptResult resultPrompt = call.PromptTTS(
2 "Welcome to SignalWire! Please enter your PIN",
3 new CallCollect
4 {
5 InitialTimeout = 10,
6 Digits = new CallCollect.DigitsParams
7 {
8 Max = 4,
9 DigitTimeout = 5,
10 }
11 },
12 gender: "male",
13 volume: 4.0);
14
15if (resultPrompt.Successful)
16{
17 // The collected input is in resultPrompt.Result
18}

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.

1PromptAction actionPrompt = call.PromptTTSAsync(
2 "Welcome to SignalWire! Please enter your PIN",
3 new CallCollect
4 {
5 InitialTimeout = 10,
6 Digits = new CallCollect.DigitsParams
7 {
8 Max = 4,
9 DigitTimeout = 5,
10 }
11 },
12 gender: "male",
13 volume: 4.0);
14
15if (actionPrompt.Completed)
16{
17 if (actionPrompt.Result.Successful)
18 {
19 // The collected input is in actionPrompt.Result.Result
20 }
21}

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.

1RecordResult resultRecord = call.Record(
2 new CallRecord
3 {
4 Audio = new CallRecord.AudioParams
5 {
6 Stereo = true,
7 Direction = CallRecord.AudioParams.AudioDirection.both,
8 }
9 });
10
11if (resultRecord.Successful)
12{
13 // The URL for the recording is available in resultRecord.Url
14}

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.

1RecordAction actionRecord = call.RecordAsync(
2 new CallRecord
3 {
4 Audio = new CallRecord.AudioParams
5 {
6 Stereo = true,
7 Direction = CallRecord.AudioParams.AudioDirection.both,
8 }
9 });
10
11Thread.Sleep(5000);
12
13actionRecord.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.

1SendDigitsResult result = call.SendDigits("123w456W789");
2
3if (result.Successful)
4{
5 // ...
6}

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.

1SendDigitsAction action = call.SendDigits("123w456W789");
2
3// 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.

1TapResult resultTap = call.Tap(
2 new CallTap
3 {
4 Audio = new CallTap.AudioParams
5 {
6 Direction = CallTap.AudioParams.AudioDirection.both,
7 }
8 },
9 new CallTapDevice
10 {
11 Type = CallTapDevice.DeviceType.rtp,
12 Parameters = new CallTapDevice.RTPParams
13 {
14 Address = "1.2.3.4",
15 Port = 12345,
16 }
17 });
18
19if (resultTap.Successful)
20{
21 // The RTP data is flowing to the device
22}

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.

1TapAction actionTap = call.TapAsync(
2 new CallTap
3 {
4 Audio = new CallTap.AudioParams
5 {
6 Direction = CallTap.AudioParams.AudioDirection.both,
7 }
8 },
9 new CallTapDevice
10 {
11 Type = CallTapDevice.DeviceType.rtp,
12 Parameters = new CallTapDevice.RTPParams
13 {
14 Address = "1.2.3.4",
15 Port = 12345,
16 }
17 });
18
19Thread.Sleep(5000);
20
21actionTap.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

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

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

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

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

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

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

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

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

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

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.

NameDescription
OnStateChangeThe call is changing state, generalized event for the following events.
OnRingingThe call is ringing and has not yet been answered.
OnAnsweredThe call has been picked up.
OnEndingThe call is hanging up.
OnEndedThe call has ended.

Connect Events

To track the connect state of a call.

NameDescription
OnConnectStateChangeThe connect state is changing, generalized event for the following events.
OnConnectFailedThe last call connection attempt failed.
OnConnectConnectingCurrently calling the phone number(s) to connect.
OnConnectConnectedThe calls are being connected together.
OnConnectDisconnectedThe call was either never connected or the last call connection completed.

Detect Events

To track a detection.

NameDescription
OnDetectErrorThe detection failed.
OnDetectFinishedThe detection has finished.
OnDetectUpdateThe detection state is changing, generalized event for the following events.

Fax Events

To track a fax operation.

NameDescription
OnFaxErrorThe fax operation failed.
OnFaxFinishedThe fax operation finished.
OnFaxPageThe fax operation sent a page.

Play Events

To track a playback state.

NameDescription
OnPlayStateChangeThe play state is changing, generalized event for the following events.
OnPlayPlayingOne of the medias are being played to the call.
OnPlayErrorThe play of media failed.
OnPlayFinishedThe playing of media has finished.

Prompt Events

To track a prompt state.

NameDescription
OnPromptThe prompt action on the call has ended.

Record Events

To track a recording state.

NameDescription
OnRecordStateChangeThe record state is changing, generalized event for the following events.
OnRecordRecordingThe call is being recorded.
OnRecordFinishedThe recording has finished.
OnRecordNoInputThe recording failed due to no input detected.

Send Digits Events

To receive a message when the digits are finished sending.

NameDescription
OnSendDigitsStateChangeThe send digits state is changing, generalized event for the following events.
OnSendDigitsFinishedThe 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.