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
      • RelayClient
        • connect
        • dial
        • disconnect
        • execute
        • onCall
        • onMessage
        • receive
        • run
        • sendMessage
        • unreceive
      • 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
RELAYRelayClient

run

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

sendMessage

Next
Built with

Async entry point that connects to RELAY and runs the event loop until interrupted. This is the recommended way to start a RelayClient for long-running services. It calls connect() internally and automatically reconnects with exponential backoff (1 second initial delay, up to 30 seconds maximum) if the connection is lost.

The method awaits until shutdown is requested. Press Ctrl+C to trigger a clean shutdown — the client handles SIGINT and SIGTERM gracefully.

For async contexts where you need manual control over the connection lifecycle, use connect() and disconnect() directly.

Parameters

None.

Returns

Promise<void> — resolves when the client is stopped via Ctrl+C or a programmatic shutdown.

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
9client.onCall(async (call) => {
10 await call.answer();
11 const action = await call.play([{ type: 'tts', text: 'Welcome! Goodbye.' }]);
12 await action.wait();
13 await call.hangup();
14});
15
16// Awaits forever, reconnects on connection loss
17await client.run();