Relay.Calling.Call
All calls in SignalWire have a common generic interface, Call. A Call is a connection between SignalWire and another device.
Properties
Methods
amd
Alias for detectAnsweringMachine.
amdAsync
Alias for detectAnsweringMachineAsync.
answer
Answer an inbound call.
Parameters
None
Returns
React\Promise\Promise - Promise object that will be fulfilled with a Relay.Calling.AnswerResult object.
Examples
Answer an inbound call and check if it was successful.
connect
Attempt to connect an existing call to a new outbound call and waits until one of the remote party picks 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
Structure of a device:
Returns
React\Promise\Promise - Promise object that will be fulfilled with a Relay.Calling.ConnectResult object.
Examples
Try connecting by calling +18991114444 and +18991114445 in series.
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.
Try connecting by calling +18991114444 and +18991114445 in series playing the US ringtone.
connectAsync
Asynchronous version of connect. It does not wait the connect to completes or fails but returns a Relay.Calling.ConnectAction you can interact with.
Parameters
See connect for the parameter list.
Returns
React\Promise\Promise - Promise object that will be fulfilled with a Relay.Calling.ConnectAction object.
Examples
Trying to connect a call by calling in series +18991114444 and +18991114445.
detect
Start a detector on the call and waits until it has finished or failed.
The detect method is a generic method for all types of detecting, see detectAnsweringMachine, detectDigit or detectFax for more specific usage.
Parameters
To detect an answering machine:
To detect digits:
To detect a fax:
Returns
React\Promise\Promise - Promise object that will be fulfilled with a Relay.Calling.DetectResult object.
Examples
Detect a machine with custom parameters and timeout.
Detect a Fax setting timeout only.
detectAsync
Asynchronous version of detect. It does not wait the detector ends but returns a Relay.Calling.DetectAction you can interact with.
Parameters
See detect for the parameter list.
Returns
React\Promise\Promise - Promise object that will be fulfilled with a Relay.Calling.DetectAction object.
Examples
Detect digits using default parameters. Stop the action immediately.
detectAnsweringMachine
This is a helper function that refines the use of detect. The Promise will be resolved with a Relay.Calling.DetectResult object as soon as the detector decided who answered the call: MACHINE, HUMAN or UNKNOWN.
Parameters
Returns
React\Promise\Promise - Promise object that will be fulfilled with a Relay.Calling.DetectResult object.
Examples
Perform an AMD and wait until the machine is ready.
detectAnsweringMachineAsync
Asynchronous version of detectAnsweringMachine. It does not wait the detector ends but returns a Relay.Calling.DetectAction you can interact with.
Parameters
See detectAnsweringMachine for the parameter list.
Returns
React\Promise\Promise - Promise object that will be fulfilled with a Relay.Calling.DetectAction object.
Examples
Perform an asynchronous AMD on the call. Then stop the action if not completed yet.
detectDigit
This is a helper function that refines the use of detect. This simplifies detecting digits on a call.
Parameters
Returns
React\Promise\Promise - Promise object that will be fulfilled with a Relay.Calling.DetectResult object.
Examples
Detect digits and then write a log with the result.
detectDigitAsync
Asynchronous version of detectDigit. It does not wait the detector ends but returns a Relay.Calling.DetectAction you can interact with.
Parameters
See detectDigit for the parameter list.
Returns
React\Promise\Promise - Promise object that will be fulfilled with a Relay.Calling.DetectAction object.
Examples
Detect only 1-3 digits asynchronously.
detectFax
This is a helper function that refines the use of detect. This simplifies detecting a fax.
Parameters
Returns
React\Promise\Promise - Promise object that will be fulfilled with a Relay.Calling.DetectResult object.
Examples
Detect fax on the current call.
detectFaxAsync
Asynchronous version of detectFax. It does not wait the detector ends but returns a Relay.Calling.DetectAction you can interact with.
Parameters
See detectFax for the parameter list.
Returns
React\Promise\Promise - Promise object that will be fulfilled with a Relay.Calling.DetectAction object.
Examples
Detect fax on the current call. Stop the action immediately.
detectHuman
This is a helper function that refines the use of detect. This simplifies detecting a human on the call and is the inverse of detectMachine.
Deprecated since: v2.2 - Use detectAnsweringMachine instead.
Parameters
Returns
React\Promise\Promise - Promise object that will be fulfilled with a Relay.Calling.DetectResult object.
Examples
Detect a human on the current call.
detectHumanAsync
Asynchronous version of detectHuman. It does not wait the detector ends but returns a Relay.Calling.DetectAction you can interact with.
Deprecated since: v2.2 - Use detectAnsweringMachineAsync instead.
Parameters
See detectHuman for the parameter list.
Returns
React\Promise\Promise - Promise object that will be fulfilled with a Relay.Calling.DetectAction object.
Examples
Detect a human on the current call. Stop the action immediately.
detectMachine
This is a helper function that refines the use of detect. This simplifies detecting a machine on the call and is the inverse of detectHuman.
Deprecated since: v2.2 - Use detectAnsweringMachine instead.
Parameters
Returns
React\Promise\Promise - Promise object that will be fulfilled with a Relay.Calling.DetectResult object.
Examples
Detect a machine on the current call.
detectMachineAsync
Asynchronous version of detectMachine. It does not wait the detector ends but returns a Relay.Calling.DetectAction you can interact with.
Deprecated since: v2.2 - Use detectAnsweringMachineAsync instead.
Parameters
See detectMachine for the parameter list.
Returns
React\Promise\Promise - Promise object that will be fulfilled with a Relay.Calling.DetectAction object.
Examples
Detect a machine on the current call. Stop the action immediately.
dial
This will start a call that was created with newCall and waits until the Call has been answered or hung up.
Parameters
None
Returns
React\Promise\Promise - Promise object that will be fulfilled with a Relay.Calling.DialResult object.
Examples
faxReceive
Prepare the call to receive an inbound fax. It waits until the fax has been received or failed.
Parameters
None
Returns
React\Promise\Promise - Promise object that will be fulfilled with a Relay.Calling.FaxResult object.
Examples
Receiving a fax on the call and print logs for URL and number of received pages.
faxReceiveAsync
Asynchronous version of faxReceive. It does not wait the fax to be received but returns Relay.Calling.FaxAction you can interact with.
Parameters
None
Returns
React\Promise\Promise - Promise object that will be fulfilled with a Relay.Calling.FaxAction object.
Examples
Trying to receive a fax and then stop it.
faxSend
Send a fax through the call. It waits until the fax has been sent or failed.
Parameters
Returns
React\Promise\Promise - Promise object that will be fulfilled with a Relay.Calling.FaxResult object.
Examples
Sending a fax on the call and print logs the number of sent pages.
faxSendAsync
Asynchronous version of faxSend. It does not wait the fax to be sent but returns a Relay.Calling.FaxAction you can interact with.
Parameters
See faxSend for the parameter list.
Returns
React\Promise\Promise - Promise object that will be fulfilled with a Relay.Calling.FaxAction object.
Examples
Trying to send a fax and then stop it.
hangup
Hangup the call.
Parameters
None
Returns
React\Promise\Promise - Promise object that will be fulfilled with a Relay.Calling.HangupResult object.
Examples
Hangup the current call and check if it was successful.
on
Attach an event handler for the event.
Parameters
Returns
Relay.Calling.Call - The call object itself.
Examples
Subscribe to the answered and ended events for a given call.
off
Remove an event handler that were attached with the on method. If you don’t pass a $handler, all listeners for that event will be removed.
Parameters
Returns
Relay.Calling.Call - The call object itself.
Examples
Subscribe to the call ended state change and then, remove the event handler.
play
Play one or multiple media in a call and waits until the playing has ended.
The play method is a generic method for all types of playing, see playAudio, playSilence, playTTS or playRingtone for more specific usage.
Parameters
To play an audio file:
To play a text to speech string:
To play silence:
To play ringtone:
Returns
React\Promise\Promise - Promise object that will be fulfilled with a Relay.Calling.PlayResult object.
Examples
Play multiple media elements in the call.
playAsync
Asynchronous version of play. It does not wait the playing to completes but returns a Relay.Calling.PlayAction you can interact with.
Parameters
See play for the parameter list.
Returns
React\Promise\Promise - Promise object that will be fulfilled with a Relay.Calling.PlayAction object.
Examples
Play multiple media elements in the call and then stop it.
playAudio
This is a helper function that refines the use of play. This simplifies playing an audio file.
Parameters
Returns
React\Promise\Promise - Promise object that will be fulfilled with a Relay.Calling.PlayResult object.
Examples
Play an Mp3 file using the signature with a string as parameter.
Play an Mp3 file setting volume level to 4dB.
playAudioAsync
Asynchronous version of playAudio. It does not wait the playing to completes but returns a Relay.Calling.PlayAction you can interact with.
Parameters
See playAudio for the parameter list.
Returns
React\Promise\Promise - Promise object that will be fulfilled with a Relay.Calling.PlayAction object.
Examples
Play an Mp3 file and stop it after 5 seconds.
Play an Mp3 file setting the volume and stop it after 5 seconds.
playRingtone
This is a helper function that refines the use of play. This simplifies play a ringtone.
Parameters
Returns
React\Promise\Promise - Promise object that will be fulfilled with a Relay.Calling.PlayResult object.
Examples
Play a single US ringtone.
playRingtoneAsync
Asynchronous version of playRingtone. It does not wait the playing to completes but returns a Relay.Calling.PlayAction you can interact with.
Parameters
See playRingtone for the parameter list.
Returns
React\Promise\Promise - Promise object that will be fulfilled with a Relay.Calling.PlayAction object.
Examples
Play US ringtone for 30 seconds, if Agent is available, stop the play.
playSilence
This is a helper function that refines the use of play. This simplifies playing silence.
Parameters
Returns
React\Promise\Promise - Promise object that will be fulfilled with a Relay.Calling.PlayResult object.
Examples
Play silence for 10 seconds.
playSilenceAsync
Asynchronous version of playSilence. It does not wait the playing to completes but returns a Relay.Calling.PlayAction you can interact with.
Parameters
See playSilence for the parameter list.
Returns
React\Promise\Promise - Promise object that will be fulfilled with a Relay.Calling.PlayAction object.
Examples
Play silence for 60 seconds, if Agent is available, stop the play.
playTTS
This is a helper function that refines the use of play. This simplifies playing TTS.
Parameters
Returns
React\Promise\Promise - Promise object that will be fulfilled with a Relay.Calling.PlayResult object.
Examples
Play TTS.
playTTSAsync
Asynchronous version of playTTS. It does not wait the playing to completes but returns a Relay.Calling.PlayAction you can interact with.
Parameters
See playTTS for the parameter list.
Returns
React\Promise\Promise - Promise object that will be fulfilled with a Relay.Calling.PlayAction object.
Examples
Play TTS and stop it after 5 seconds.
prompt
Play one or multiple 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.
The prompt method is a generic method, see promptAudio, promptTTS or promptRingtone for more specific usage.
Parameters
To collect digits:
To collect speech:
Returns
React\Promise\Promise - Promise object that will be fulfilled with a Relay.Calling.PromptResult object.
Examples
Ask user to enter their PIN and collect the digits.
promptAsync
Asynchronous version of prompt. It does not wait the collection to completes but returns a Relay.Calling.PromptAction you can interact with.
Parameters
See prompt for the parameter list.
Returns
React\Promise\Promise - Promise object that will be fulfilled with a Relay.Calling.PromptAction object.
Examples
Ask user to enter their PIN and collect the digits.
promptAudio
This is a helper function that refines the use of prompt.
This function simplifies playing an audio file while collecting user’s input from the call, such as digits and speech.
Parameters
You can set all the properties that prompt accepts replacing media with:
The SDK will build the media for you.
Returns
React\Promise\Promise - Promise object that will be fulfilled with a Relay.Calling.PromptResult object.
Examples
Collect user’s digits while playing an Mp3 file.
promptAudioAsync
Asynchronous version of promptAudio. It does not wait the collection to completes but returns a Relay.Calling.PromptAction you can interact with.
Parameters
See promptAudio for the parameter list.
Returns
React\Promise\Promise - Promise object that will be fulfilled with a Relay.Calling.PromptAction object.
Examples
Ask user to enter their PIN and collect the digits.
promptRingtone
This is a helper function that refines the use of prompt.
This function simplifies playing ringtone while collecting user’s input from the call, such as digits and speech.
Parameters
You can set all the properties that prompt accepts replacing media with:
Returns
React\Promise\Promise - Promise object that will be fulfilled with a Relay.Calling.PromptResult object.
Examples
Play US ringtone for 30 seconds while collect digits.
promptRingtoneAsync
Asynchronous version of promptRingtone. It does not wait the collection to completes but returns a Relay.Calling.PromptAction you can interact with.
Parameters
See promptRingtone for the parameter list.
Returns
React\Promise\Promise - Promise object that will be fulfilled with a Relay.Calling.PromptAction object.
Examples
Play US ringtone for 30 seconds while collect digits in asynchronous.
promptTTS
This is a helper function that refines the use of prompt.
This function simplifies playing TTS while collecting user’s input from the call, such as digits and speech.
Parameters
You can set all the properties that prompt accepts replacing media with:
Returns
React\Promise\Promise - Promise object that will be fulfilled with a Relay.Calling.PromptResult object.
Examples
Ask user to enter their PIN and collect the digits.
promptTTSAsync
Asynchronous version of promptTTS. It does not wait the collection to completes but returns a Relay.Calling.PromptAction you can interact with.
Parameters
See promptTTS for the parameter list.
Returns
React\Promise\Promise - Promise object that will be fulfilled with a Relay.Calling.PromptAction object.
Examples
Ask user to enter their PIN and collect the digits.
record
Start recording the call and waits until the recording ends or fails.
Parameters
Returns
React\Promise\Promise - Promise object that will be fulfilled with a Relay.Calling.RecordResult object.
Examples
Start recording audio in the call for both direction in stereo mode, if successful, grab url, duration and size from the RecordResult object.
recordAsync
Asynchronous version of record. It does not wait the end of recording but returns a Relay.Calling.RecordAction you can interact with.
Parameters
See record for the parameter list.
Returns
React\Promise\Promise - Promise object that will be fulfilled with a Relay.Calling.RecordAction object.
Examples
Start recording audio in the call for both direction in stereo mode and then stop it using the RecordAction object.
sendDigits
This method sends DTMF digits to the other party on the call. Allowed digits are 1234567890*#ABCD and wW for short and long waits. If any invalid characters are present, the entire operation is rejected.
Parameters
Returns
React\Promise\Promise - Promise object that will be fulfilled with a Relay.Calling.SendDigitsResult object.
Examples
Send some digits.
sendDigitsAsync
Asynchronous version of sendDigits. It does not wait for the sending event to complete, and immediately returns a Relay.Calling.SendDigitsAction object you can interact with.
Parameters
See sendDigits for the parameter list.
Returns
React\Promise\Promise - Promise object that will be fulfilled with a Relay.Calling.SendDigitsAction.
Examples
Send some digits and then check if the operation is completed using the SendDigitsAction object.
tap
Intercept call media and stream it to the specify endpoint. It waits until the end of the call.
Parameters
To tap through RTP:
Returns
React\Promise\Promise - Promise object that will be fulfilled with a Relay.Calling.TapResult object.
Examples
Tapping audio from the call, if successful, print both source and destination devices from the TapResult object.
tapAsync
Asynchronous version of tap. It does not wait the end of tapping but returns a Relay.Calling.TapAction you can interact with.
Parameters
See tap for the parameter list.
Returns
React\Promise\Promise - Promise object that will be fulfilled with a Relay.Calling.TapAction object.
Examples
Tapping audio from the call and then stop it using the TapAction object.
waitFor
Wait for specific events on the Call or returns false if the Call ends without getting them.
Parameters
Returns
React\Promise\Promise - Promise object that will be fulfilled with true or false.
Examples
Wait for ending or ended events.
waitForAnswered
This is a helper function that refines the use of waitFor. This simplifies waiting for the answered state.
Parameters
None
Returns
React\Promise\Promise - Promise object that will be fulfilled with true or false.
Examples
Wait for the answered event.
waitForEnded
This is a helper function that refines the use of waitFor. This simplifies waiting for the ended state.
Parameters
None
Returns
React\Promise\Promise - Promise object that will be fulfilled with true or false.
Examples
Wait for the ended event.
waitForEnding
This is a helper function that refines the use of waitFor. This simplifies waiting for the ending state.
Parameters
None
Returns
React\Promise\Promise - Promise object that will be fulfilled with true or false.
Examples
Wait for the ending event.
waitForRinging
This is a helper function that refines the use of waitFor. This simplifies waiting for the ringing state.
Parameters
None
Returns
React\Promise\Promise - Promise object that will be fulfilled with true or false.
Examples
Wait for ending or ended events.
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.
Connect Events
To track the connect state of a call.
Play Events
To track a playback state.
Record Events
To track a recording state.
Prompt Events
To track a prompt state.
Fax Events
To track a fax state.
Detect Events
To track a detector state.
Tap Events
To track a tapping state.
Digits Events
To track a send digits action state.
Ringtones
Here you can find all the accepted values for the ringtone to play, based on short country codes: