Events
RELAY events are delivered as typed class instances that wrap the raw JSON-RPC
event payloads from the SignalWire WebSocket connection. When you register a handler
with Call.on() or
Message.on(), the handler
automatically receives a typed event object with named properties for each field.
All typed event classes inherit from RelayEvent, which provides
access to the raw params dictionary alongside the typed properties. You can also
use the parseEvent() helper to manually parse raw event payloads.
RelayEvent
Base event class. All other event classes inherit from this. Every handler receives
at minimum a RelayEvent instance, which provides access to the raw event data.
eventType
The event type string (e.g., "calling.call.state", "messaging.receive").
See Constants for the full list.
params
The raw parameters dictionary from the event payload. Contains all event-specific fields, including those not surfaced as typed attributes on subclasses.
callId
The call identifier associated with this event, if applicable.
timestamp
Server timestamp of the event.
Methods
fromPayload
Static method. Parse a raw event object into a RelayEvent instance.
Parameters
payload
Raw event payload dictionary.
payload.event_type
The event type string (e.g., "calling.call.state").
payload.params
Event-specific parameters.
Returns
RelayEvent — A new event instance with typed properties.
Example
parseEvent
Standalone helper function. Parses a raw event object and returns the appropriate
typed event subclass based on the event_type field. Falls back to RelayEvent
for unrecognized event types.
Parameters
payload
Raw event payload dictionary.
payload.event_type
The event type string (e.g., "calling.call.state", "calling.call.play").
Determines which typed subclass is returned.
payload.params
Event-specific parameters. Contents vary by event type.
Returns
RelayEvent — The appropriate typed subclass based on the
event_type field, or a base RelayEvent for unrecognized types.
Example
Calling Events
calling.call.state
Emitted when the call state changes through its lifecycle: created ->
ringing -> answered -> ending -> ended.
CallStateEvent
Handlers for this event receive a CallStateEvent with the following properties:
callState
The new call state.
"created"— call object has been initialized"ringing"— call is ringing at the destination"answered"— call has been answered and is active"ending"— hangup is in progress"ended"— call has been fully terminated
endReason
Reason the call ended. Only present when callState is "ended".
"hangup"— normal disconnect by a party on the call"cancel"— call was cancelled before being answered"busy"— destination signaled busy"noAnswer"— call rang but was not answered within the timeout"decline"— destination actively declined the call"error"— an error occurred during call processing"abandoned"— caller hung up before the call was answered"max_duration"— call reached the maximum allowed duration"not_found"— destination could not be found or routed
direction
Call direction.
"inbound"— incoming call"outbound"— outgoing call
device
Device information for the call endpoint.
Example
calling.call.receive
Emitted when an inbound call is received on a subscribed context. This event is
dispatched at the client level via client.onCall() rather than
through call.on().
CallReceiveEvent
Handlers for this event receive a CallReceiveEvent with the following properties:
callState
Initial call state (typically "ringing").
direction
Always "inbound" for receive events.
device
Device information for the caller.
nodeId
RELAY node handling this call.
projectId
SignalWire project ID.
context
The context the call was received on.
segmentId
Call segment identifier.
tag
Correlation tag for the call.
calling.call.play
Emitted when playback state changes on a play operation.
PlayEvent
Handlers for this event receive a PlayEvent with the following properties:
controlId
The control ID of the play operation. Matches the control_id on the
PlayAction.
state
Playback state.
"playing"— audio is actively playing"paused"— playback has been paused"finished"— playback completed successfully"error"— an error occurred during playback
Example
calling.call.record
Emitted when recording state changes on a record operation.
RecordEvent
Handlers for this event receive a RecordEvent with the following properties:
controlId
The control ID of the record operation.
state
Recording state.
"recording"— audio recording is in progress"paused"— recording has been paused"finished"— recording completed successfully"no_input"— recording ended due to no audio input detected
url
URL of the recording file (available when state is "finished").
duration
Recording duration in seconds.
size
Recording file size in bytes.
record
Full record metadata object containing url, duration, size, and other fields.
Example
calling.call.collect
Emitted when input collection state changes on a
collect() or
playAndCollect()
operation.
CollectEvent
Handlers for this event receive a CollectEvent with the following properties:
controlId
The control ID of the collect operation.
state
Collection state.
"finished"— input was collected successfully"error"— an error occurred during collection"no_input"— no input was detected within the timeout"no_match"— collected input did not match any configured patterns
result
The collected input result. Contains type and the collected value.
"digit"— DTMF digit input was collected"speech"— speech input was collected
final
Whether this is the final result. May be undefined for non-continuous collect operations.
Example
calling.call.connect
Emitted when a connect operation changes state.
ConnectEvent
Handlers for this event receive a ConnectEvent with the following properties:
connectState
Connection state.
"connecting"— bridge is being established to the destination"connected"— bridge has been successfully established"disconnected"— bridge has been disconnected"failed"— connection attempt failed
peer
Information about the connected peer call.
Example
calling.call.detect
Emitted when detection results arrive from a detect operation.
DetectEvent
Handlers for this event receive a DetectEvent with the following properties:
controlId
The control ID of the detect operation.
detect
Detection result. Structure depends on the detection type.
"machine"— voicemail or answering machine detection"fax"— fax tone detection"digit"— DTMF digit detection
Example
calling.call.fax
Emitted when a sendFax() or
receiveFax() operation
changes state.
FaxEvent
Handlers for this event receive a FaxEvent with the following properties:
controlId
The control ID of the fax operation.
fax
Fax result data including pages, status, and document URL.
Example
calling.call.tap
Emitted when a tap operation changes state.
TapEvent
Handlers for this event receive a TapEvent with the following properties:
controlId
The control ID of the tap operation.
state
Tap state.
"finished"— tap operation completed
tap
Tap configuration details.
device
The device receiving the tapped media.
Example
calling.call.stream
Emitted when a stream operation changes state.
StreamEvent
Handlers for this event receive a StreamEvent with the following properties:
controlId
The control ID of the stream operation.
state
Stream state.
"finished"— stream operation completed
url
The WebSocket URL the stream is connected to.
name
The stream name.
Example
calling.call.send_digits
Emitted when a send_digits operation changes state.
SendDigitsEvent
Handlers for this event receive a SendDigitsEvent with the following properties:
controlId
The control ID of the send_digits operation.
state
Send digits state.
Example
calling.call.dial
Emitted during outbound dial state changes. This event is dispatched at the
client level rather than through call.on().
DialEvent
Handlers for this event receive a DialEvent with the following properties:
tag
Correlation tag for the dial operation.
dialState
Dial state.
"answered"— outbound call was answered"failed"— outbound call failed to connect
call
Call information for the dialed leg.
calling.call.refer
Emitted when a SIP REFER operation changes state.
ReferEvent
Handlers for this event receive a ReferEvent with the following properties:
state
Refer state.
sipReferTo
The SIP URI the call was referred to.
sipReferResponseCode
SIP response code from the REFER request.
sipNotifyResponseCode
SIP response code from the NOTIFY message.
Example
calling.call.hold
Emitted when hold state changes via
hold() or
unhold().
HoldEvent
Handlers for this event receive a HoldEvent with the following properties:
state
Hold state.
Example
calling.call.denoise
Emitted when noise reduction state changes.
DenoiseEvent
Handlers for this event receive a DenoiseEvent with the following properties:
denoised
Whether noise reduction is currently active.
Example
calling.call.pay
Emitted when a pay operation changes state.
PayEvent
Handlers for this event receive a PayEvent with the following properties:
controlId
The control ID of the pay operation.
state
Payment state.
"finished"— payment collection completed"error"— payment operation failed
Example
calling.call.echo
Emitted when an echo operation changes state.
EchoEvent
Handlers for this event receive an EchoEvent with the following properties:
state
Echo state.
Example
calling.call.queue
Emitted when queue state changes via
queueEnter() or
queueLeave().
QueueEvent
Handlers for this event receive a QueueEvent with the following properties:
controlId
The control ID of the queue operation.
status
Queue status.
queueId
The queue identifier.
queueName
The queue name.
position
Current position in the queue.
size
Total number of calls in the queue.
Example
calling.conference
Emitted when conference state changes.
ConferenceEvent
Handlers for this event receive a ConferenceEvent with the following properties:
conferenceId
The conference identifier.
name
The conference name.
status
Conference status.
Example
calling.call.transcribe
Emitted when a transcribe operation changes state.
TranscribeEvent
Handlers for this event receive a TranscribeEvent with the following properties:
controlId
The control ID of the transcribe operation.
state
Transcription state.
"finished"— transcription completed successfully
url
URL of the transcription result.
recordingId
Associated recording ID.
duration
Duration of the transcribed audio in seconds.
size
Size of the transcription data in bytes.
Example
calling.error
Emitted when an error occurs on the call.
CallingErrorEvent
Handlers for this event receive a CallingErrorEvent with the following properties:
code
Error code.
message
Human-readable error description.
Example
Messaging Events
messaging.receive
Emitted when an inbound SMS/MMS message is received on a subscribed context.
This event is dispatched at the client level via client.onMessage().
MessageReceiveEvent
Handlers for this event receive a MessageReceiveEvent with the following properties:
messageId
Unique identifier for the message.
context
The messaging context the message was received on.
direction
Always "inbound" for receive events.
fromNumber
Sender phone number in E.164 format.
toNumber
Recipient phone number in E.164 format.
body
Text content of the message.
media
Media URLs for MMS messages.
segments
Number of SMS segments.
messageState
State of the message (typically "received").
tags
Tags associated with the message.
messaging.state
Emitted when an outbound message’s state changes (e.g., queued -> sent -> delivered).
MessageStateEvent
Handlers for this event receive a MessageStateEvent with the following properties:
messageId
Unique identifier for the message.
context
The messaging context.
direction
Always "outbound" for state events.
fromNumber
Sender phone number in E.164 format.
toNumber
Recipient phone number in E.164 format.
body
Text content of the message.
media
Media URLs for MMS messages.
segments
Number of SMS segments.
messageState
Current message state.
"queued"— message accepted by the platform, waiting to be sent"initiated"— message sending has been initiated"sent"— message has been sent to the carrier"delivered"— message has been delivered to the recipient"undelivered"— message could not be delivered"failed"— message sending failed
reason
Failure reason if the message failed or was undelivered.
tags
Tags associated with the message.
Example
Event Type Mapping
Reference table mapping event_type strings to their typed event classes.