feat(call, voicemail, ivr): add voicemail and IVR call flows with DTMF handling, prompt playback, recording, and dashboard management

This commit is contained in:
2026-04-10 08:54:46 +00:00
parent 6ecd3f434c
commit e6bd64a534
25 changed files with 3892 additions and 10 deletions

View File

@@ -188,3 +188,54 @@ export function parseSdpEndpoint(sdp: string): { address: string; port: number }
}
return addr && port ? { address: addr, port } : null;
}
// ---------------------------------------------------------------------------
// MWI (Message Waiting Indicator) — RFC 3842
// ---------------------------------------------------------------------------
/**
* Build a SIP NOTIFY request for Message Waiting Indicator.
*
* Sent out-of-dialog to notify a device about voicemail message counts.
* Uses the message-summary event package per RFC 3842.
*/
export interface IMwiOptions {
/** Proxy LAN IP and port (Via / From / Contact). */
proxyHost: string;
proxyPort: number;
/** Target device URI (e.g. "sip:user@192.168.5.100:5060"). */
targetUri: string;
/** Account URI for the voicebox (used in the From header). */
accountUri: string;
/** Number of new (unheard) voice messages. */
newMessages: number;
/** Number of old (heard) voice messages. */
oldMessages: number;
}
/**
* Build the body and headers for an MWI NOTIFY (RFC 3842 message-summary).
*
* Returns the body string and extra headers needed. The caller builds
* the SipMessage via SipMessage.createRequest('NOTIFY', ...).
*/
export function buildMwiBody(newMessages: number, oldMessages: number, accountUri: string): {
body: string;
contentType: string;
extraHeaders: [string, string][];
} {
const hasNew = newMessages > 0;
const body =
`Messages-Waiting: ${hasNew ? 'yes' : 'no'}\r\n` +
`Message-Account: ${accountUri}\r\n` +
`Voice-Message: ${newMessages}/${oldMessages}\r\n`;
return {
body,
contentType: 'application/simple-message-summary',
extraHeaders: [
['Event', 'message-summary'],
['Subscription-State', 'terminated;reason=noresource'],
],
};
}