Add web provider inbound monitor with auto-replies

This commit is contained in:
Peter Steinberger
2025-11-24 18:33:50 +01:00
parent 5ee4f3219d
commit 9b4dceecfe
4 changed files with 474 additions and 48 deletions

View File

@@ -35,6 +35,14 @@ export function toWhatsappJid(number: string): string {
return `${digits}@s.whatsapp.net`;
}
export function jidToE164(jid: string): string | null {
// Convert a WhatsApp JID (with optional device suffix, e.g. 1234:1@s.whatsapp.net) back to +1234.
const match = jid.match(/^(\d+)(?::\d+)?@s\.whatsapp\.net$/);
if (!match) return null;
const digits = match[1];
return `+${digits}`;
}
export function sleep(ms: number) {
return new Promise((resolve) => setTimeout(resolve, ms));
}