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

execute

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

onCall

Next
Built with

Send a raw JSON-RPC 2.0 request to the RELAY server and return the parsed response. This is the low-level RPC method that all other client and call control methods are built on.

If the client is not currently connected (e.g., during a reconnect cycle), the request is automatically queued and sent after re-authentication completes.

This method has a default timeout of 30 seconds. If no response is received within that window, it throws RelayError and forces a reconnection attempt, as the timeout may indicate a half-open WebSocket connection.

Most developers should use the higher-level methods like dial(), sendMessage(), and the Call control methods instead of calling execute() directly. Use execute() only for custom or unsupported RPC methods.

Parameters

method
stringRequired

Full JSON-RPC method name (e.g., "calling.answer", "calling.play", "messaging.send"). The method name must include the namespace prefix.

params
Record<string, unknown>Required

Parameters for the RPC call. Typically includes node_id and call_id for calling methods, along with method-specific parameters.

Returns

Promise<Record<string, unknown>> — The result object from the JSON-RPC response. Structure depends on the method called.

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 // Send a custom RPC request using the call's identifiers
11 const result = await client.execute('calling.answer', {
12 node_id: call.nodeId,
13 call_id: call.callId,
14 });
15 console.log(`Answer result: ${JSON.stringify(result)}`);
16});
17
18await client.run();