Skip to navigation

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

options.event
stringRequired

The event name or identifier.

The options type also accepts additional keys (& Record<string, unknown>), and the SDK sends every field. SignalWire accepts only event: a request without it, or with any other key, fails with a bad request error.

Returns

Promise<CallingUserEventResult> — 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();