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

1import { RelayClient } from '@signalwire/sdk';
2
3const client = new RelayClient({
4 project: process.env.SIGNALWIRE_PROJECT_ID!,
5 token: process.env.SIGNALWIRE_TOKEN!,
6 contexts: ['default']
7});
8
9client.onCall(async (call) => {
10 await call.answer();
11
12 const action = await call.receiveFax();
13 const event = await action.wait();
14
15 const faxResult = event.params.fax as Record<string, unknown> ?? {};
16 const documentUrl = (faxResult.document ?? '') as string;
17 const pages = faxResult.pages ?? 0;
18 console.log(`Received fax: ${pages} pages, document: ${documentUrl}`);
19 await call.hangup();
20});
21
22await client.run();