receiveFax

View as MarkdownOpen in Claude

Start receiving a fax on the call. Returns a FaxAction that resolves when the fax is fully received or an error occurs.

This method emits calling.call.fax events. See Call Events for payload details.

Parameters

controlId
string | undefined

Custom control ID. Auto-generated if not provided.

onCompleted
(event: RelayEvent) => void | Promise<void>

Callback invoked when the fax reception completes. The event contains the received document URL and page count.

Returns

Promise<FaxAction> — An action handle with stop() and wait() methods.

Example

import { RelayClient } from '@signalwire/sdk';
const client = new RelayClient({
project: process.env.SIGNALWIRE_PROJECT_ID!,
token: process.env.SIGNALWIRE_API_TOKEN!,
contexts: ['default']
});
client.onCall(async (call) => {
await call.answer();
const action = await call.receiveFax();
const event = await action.wait();
const faxResult = event.params.fax as Record<string, unknown> ?? {};
const documentUrl = (faxResult.document ?? '') as string;
const pages = faxResult.pages ?? 0;
console.log(`Received fax: ${pages} pages, document: ${documentUrl}`);
await call.hangup();
});
await client.run();