meowcaller-js / Docs / Client

Client

The Client is the main entry point. It wraps a Baileys socket and manages call lifecycle.

import { Client } from 'meowcaller-js';

const client = new Client(wa, { logger });
client.connect();

Constructor

new Client(wa, opts?)
ParameterTypeDescription
waWASocketA connected Baileys socket
optsConfigOption | ConfigOption[]Optional configuration (logger, diagnostics)

The opts parameter accepts configuration functions:

import { Client, WithLogger, WithDiagnostics } from 'meowcaller-js';
import { Recorder } from 'meowcaller-js/src/diag.js';

const client = new Client(wa, [
  WithLogger(pino({ level: 'debug' })),
  WithDiagnostics(new Recorder('calls.jsonl')),
]);

Methods

client.connect()

Installs call event handlers on the Baileys socket. Call this after the socket is created but before or after it connects — the handlers will fire when WhatsApp sends call events.

Returns this for chaining.

client.connect();
// or
const self = client.connect();

client.call(ctx, target)

Place an outbound voice call.

ParameterTypeDescription
ctxanyContext (reserved for future use, pass {})
targetstringPhone number with + prefix or full JID

Returns Promise<Call>.

const call = await client.call({}, '+15551234567');
call.onEnd((reason) => console.log(reason));

The target is resolved to a WhatsApp JID internally:

  • +1555123456715551234567@s.whatsapp.net
  • 15551234567@s.whatsapp.net → used as-is

client.onIncomingCall(fn)

Register a callback for incoming call offers.

client.onIncomingCall((call) => {
  console.log('incoming call from', call.peer());
  call.answer();
});

Only one handler can be active at a time. Calling this again replaces the previous handler.

client.listCalls()

Returns an array of all active Call or CallSession objects in the registry.

const calls = client.listCalls();
for (const c of calls) {
  console.log(c.id(), c.state());
}

client.getCall(callID)

Look up a specific call by its ID.

ParameterTypeDescription
callIDstringThe call ID

Returns Call, CallSession, or null.

const call = client.getCall('ABCDEF1234567890');
if (call) {
  console.log(call.state());
}

Properties

PropertyTypeDescription
client.waWASocketThe underlying Baileys socket
client.logLogger | nullLogger instance if configured
client.registryCallRegistryThe call registry