> Fetch clean Markdown by appending `.md` to any page URL under https://signalwire.com/docs or requesting it with the HTTP header `Accept: text/markdown`. The root index at https://signalwire.com/docs/llms.txt lists the available documentation indexes. # Constants > Relay constants for call states, connect states, event types, and message states. [connectevent-connectstate]: /docs/server-sdks/reference/typescript/relay/events [call-on]: /docs/server-sdks/reference/typescript/relay/call [relayevent-eventtype]: /docs/server-sdks/reference/typescript/relay/events The `@signalwire/sdk` package re-exports string constants for call states, connect states, event types, and message states. Import any of them from the package root: ```typescript {2-7} import { CALL_STATE_ANSWERED, CALL_STATE_ENDED, CONNECT_STATE_CONNECTED, EVENT_CALL_STATE, MESSAGE_STATE_DELIVERED, } from '@signalwire/sdk'; ``` ## Call States Constants representing the lifecycle states of a Relay call. A call progresses through these states in order: `created` -> `ringing` -> `answered` -> `ending` -> `ended`. | Constant | Value | Description | | --------------------- | ------------ | ---------------------------------- | | `CALL_STATE_CREATED` | `"created"` | Call object has been created | | `CALL_STATE_RINGING` | `"ringing"` | Call is ringing at the destination | | `CALL_STATE_ANSWERED` | `"answered"` | Call has been answered | | `CALL_STATE_ENDING` | `"ending"` | Call is in the process of ending | | `CALL_STATE_ENDED` | `"ended"` | Call has ended | --- ## Connect States Constants representing the state of a call bridge (connect) operation. Used in [`ConnectEvent.connectState`][connectevent-connectstate]. | Constant | Value | Description | | ---------------------------- | ---------------- | ---------------------------- | | `CONNECT_STATE_CONNECTING` | `"connecting"` | Bridge is being established | | `CONNECT_STATE_CONNECTED` | `"connected"` | Bridge is active | | `CONNECT_STATE_DISCONNECTED` | `"disconnected"` | Bridge has been disconnected | | `CONNECT_STATE_FAILED` | `"failed"` | Bridge attempt failed | --- ## Event Types String constants for Relay event types. Use these when registering event handlers with [`Call.on()`][call-on] or when matching against [`RelayEvent.eventType`][relayevent-eventtype]. ### Calling Events | Constant | Value | | ------------------------ | ---------------------------- | | `EVENT_CALL_STATE` | `"calling.call.state"` | | `EVENT_CALL_RECEIVE` | `"calling.call.receive"` | | `EVENT_CALL_CONNECT` | `"calling.call.connect"` | | `EVENT_CALL_PLAY` | `"calling.call.play"` | | `EVENT_CALL_COLLECT` | `"calling.call.collect"` | | `EVENT_CALL_RECORD` | `"calling.call.record"` | | `EVENT_CALL_DETECT` | `"calling.call.detect"` | | `EVENT_CALL_FAX` | `"calling.call.fax"` | | `EVENT_CALL_TAP` | `"calling.call.tap"` | | `EVENT_CALL_SEND_DIGITS` | `"calling.call.send_digits"` | | `EVENT_CALL_DIAL` | `"calling.call.dial"` | | `EVENT_CALL_REFER` | `"calling.call.refer"` | | `EVENT_CALL_DENOISE` | `"calling.call.denoise"` | | `EVENT_CALL_PAY` | `"calling.call.pay"` | | `EVENT_CALL_QUEUE` | `"calling.call.queue"` | | `EVENT_CALL_STREAM` | `"calling.call.stream"` | | `EVENT_CALL_ECHO` | `"calling.call.echo"` | | `EVENT_CALL_TRANSCRIBE` | `"calling.call.transcribe"` | | `EVENT_CALL_HOLD` | `"calling.call.hold"` | | `EVENT_CONFERENCE` | `"calling.conference"` | | `EVENT_CALLING_ERROR` | `"calling.error"` | ### Messaging Events | Constant | Value | | ------------------------- | --------------------- | | `EVENT_MESSAGING_RECEIVE` | `"messaging.receive"` | | `EVENT_MESSAGING_STATE` | `"messaging.state"` | --- ## Message States Constants representing the lifecycle states of an SMS/MMS message. Outbound messages progress through: `queued` -> `initiated` -> `sent` -> `delivered` (or `undelivered` / `failed`). Inbound messages arrive with state `received`. | Constant | Value | Description | | --------------------------- | --------------- | -------------------------------------- | | `MESSAGE_STATE_QUEUED` | `"queued"` | Message has been queued for sending | | `MESSAGE_STATE_INITIATED` | `"initiated"` | Send process has started | | `MESSAGE_STATE_SENT` | `"sent"` | Message has been sent to the carrier | | `MESSAGE_STATE_DELIVERED` | `"delivered"` | Message was delivered to the recipient | | `MESSAGE_STATE_UNDELIVERED` | `"undelivered"` | Message could not be delivered | | `MESSAGE_STATE_FAILED` | `"failed"` | Message send failed | | `MESSAGE_STATE_RECEIVED` | `"received"` | Inbound message received | ## Typed state unions Each state family also has a string-literal union type, the list of its terminal values, and a predicate, so you can narrow states without comparing against individual constants. | Type | Terminal values | Predicate | | --------------------------------------------- | ------------------------------------------------------------------- | ------------------------------- | | `CallState` | `CALL_STATE_TERMINAL` = `["ended"]` | `isCallStateTerminal(state)` | | `DialState` (`dialing`, `answered`, `failed`) | `DIAL_STATE_TERMINAL` = `["answered", "failed"]` | `isDialStateTerminal(state)` | | `MessageState` | `MESSAGE_STATE_TERMINAL` = `["delivered", "undelivered", "failed"]` | `isMessageStateTerminal(state)` | Two more closed sets are exported for method options: `TtsGender` (`"male"` or `"female"`) and `FaxTone` (`"CED"` or `"CNG"`). ```typescript {1,4} import { isMessageStateTerminal, type MessageState } from '@signalwire/sdk'; function handleMessageState(message: { state: MessageState }) { if (isMessageStateTerminal(message.state)) { console.log('Message delivery complete'); } } ``` ## **Example** ```typescript {11,20} import { CALL_STATE_ANSWERED, CALL_STATE_ENDED, EVENT_CALL_STATE, isMessageStateTerminal, } from '@signalwire/sdk'; import type { CallStateEvent } from '@signalwire/sdk'; // Use in event handlers function handleCallState(event: CallStateEvent) { if (event.callState === CALL_STATE_ANSWERED) { console.log('Call answered!'); } else if (event.callState === CALL_STATE_ENDED) { console.log(`Call ended: ${event.endReason}`); } } // Check terminal message states function handleMessageState(message: { state: string }) { if (isMessageStateTerminal(message.state)) { console.log('Message delivery complete'); } } ``` > Relay constants for call states, connect states, event types, and message states.