Extracts phone digits from WhatsApp JIDs and filters out non-phone chat IDs like groups, broadcasts, and newsletters. Reuse when normalizing WhatsApp identifiers to phone numbers.
// Source: https://github.com/devlikeapro/waha | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
// Provided via justclaw.it.com; keep this notice with the code.
import {
isJidBroadcast,
isJidGroup,
isJidMetaAI,
isJidNewsletter,
isLidUser,
} from '@waha/core/utils/jids';
export function extractPhoneDigits(value: string): string {
if (!value) {
return '';
}
const local = value.split('@')[0] ?? value;
return local.split(':')[0].replace(/\D/g, '');
}
/**
* Chats that are not phone numbers - groups, lids, newsletters, etc.
*/
export function shouldSkipPhoneNormalization(chatId: string): boolean {
if (!chatId) {
return true;
}
if (isJidGroup(chatId)) {
return true;
}
if (isJidBroadcast(chatId)) {
return
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key