For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
Log inSign up
Support
GuidesReference
GuidesReference
    • Core
      • Overview
    • Agents
      • Overview
      • AgentBase
      • AgentServer
      • Configuration
      • ContextBuilder
      • DataMap
      • FunctionResult
      • Helper Functions & Utilities
      • LiveWire
      • PomBuilder
      • Prefabs
      • SkillBase
      • SkillManager
      • SkillRegistry
      • Skills
      • SwaigFunction
      • SwmlBuilder
      • SWMLService
    • RELAY
      • Overview
      • Actions
      • Call
      • Constants
      • Events
      • Message
        • on
        • wait
      • RelayClient
      • RelayError
    • REST Client
      • Overview
      • Addresses
      • Calling
      • ChatResource
      • Compat
      • Datasphere
      • Fabric
      • ImportedNumbersResource
      • Logs
      • LookupResource
      • MFA
      • Number Groups
      • Phone Numbers
      • Project
      • PubSubResource
      • Queues
      • Recordings
      • Registry
      • RestClient
      • RestError
      • Short Codes
      • SIP Profile
      • Verified Callers
      • Video
LogoLogoSignalWire Docs
Log inSign up
Support
On this page
  • Parameters
  • Returns
  • Example
RELAYMessage

wait

|View as Markdown|Open in Claude|
Was this page helpful?
Edit this page
Previous

RelayClient

Next
Built with

Await until the message reaches a terminal state (delivered, undelivered, or failed). Returns the terminal RelayEvent.

Throws an Error if timeout is specified and the message does not reach a terminal state within the given duration.

Parameters

timeout
number | undefined

Maximum seconds to wait (matches Python SDK convention). undefined waits indefinitely.

Returns

Promise<RelayEvent> — The event that caused the message to reach its terminal state. Inspect message.state for the final state value.

Example

1import { RelayClient } from '@signalwire/sdk';
2
3const client = new RelayClient({
4 project: process.env.SIGNALWIRE_PROJECT_ID!,
5 token: process.env.SIGNALWIRE_API_TOKEN!,
6 contexts: ['default']
7});
8
9await client.connect();
10
11const message = await client.sendMessage({
12 toNumber: '+15551234567',
13 fromNumber: '+15559876543',
14 body: 'Your verification code is 123456',
15});
16
17try {
18 const event = await message.wait(30);
19 if (message.state === 'delivered') {
20 console.log('Message delivered successfully');
21 } else {
22 console.log(`Message failed: ${message.reason}`);
23 }
24} catch (err) {
25 console.log('Timed out waiting for delivery confirmation');
26}
27
28await client.disconnect();