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

import { AgentBase } from '@signalwire/sdk';
const username = AgentBase.extractSipUsername({
call: { to: 'sip:helpdesk@example.com' },
});
console.log(username); // "helpdesk"
const noMatch = AgentBase.extractSipUsername({});
console.log(noMatch); // null