userEvent

View as MarkdownOpen in Claude

Send a custom user-defined event on the call. User events allow you to pass application-specific data through the Relay event system. Other listeners on the same call can receive and react to these events.

Parameters

event
string | undefined

The event name or identifier.

The options type also accepts additional keys (& Record<string, unknown>), but only the event field is extracted and sent in the RPC call.

Returns

Promise<Record<string, unknown>> — Server response confirming the event was sent.

Example

import { RelayClient } from '@signalwire/sdk';
const client = new RelayClient({
project: process.env.SIGNALWIRE_PROJECT_ID!,
token: process.env.SIGNALWIRE_API_TOKEN!,
contexts: ['default']
});
client.onCall(async (call) => {
await call.answer();
// Send a custom event
const result = await call.userEvent({
event: 'customer_identified',
});
console.log(`User event sent: ${JSON.stringify(result)}`);
});
await client.run();