extractSipUsername

View as MarkdownOpen in Claude

Static method that extracts the SIP username from a request body’s call.to field. Strips the sip: or sips: protocol prefix and the @domain suffix, returning just the username portion.

Parameters

requestBody
Record<string, unknown>Required

The parsed request body containing call information. Expected to have a call.to field in SIP URI format (e.g., "sip:helpdesk@example.com").

Returns

string | null — The extracted SIP username, or null if not found.

Example

1import { AgentBase } from '@signalwire/sdk';
2
3const username = AgentBase.extractSipUsername({
4 call: { to: 'sip:helpdesk@example.com' },
5});
6console.log(username); // "helpdesk"
7
8const noMatch = AgentBase.extractSipUsername({});
9console.log(noMatch); // null