detectFax

View as Markdown

detectFax

Detects the presence of a fax machine.

Parameters

params
object

Object containing the parameters for fax detection.

timeout
numberDefaults to 30.0

Number of seconds to run the detector for.

tone
"CED" | "CNG"Defaults to CED

The fax tone to detect: CED or CNG.

waitForBeep
booleanDefaults to false

Whether to wait until the device is ready for voicemail delivery.

listen
object

Callback to listen for events. List of detect events can be found here. Example event: onStarted.

Returns

Promise<CallDetect>

A promise that resolves to a CallDetect object that you can use to view the current state and results of the detect session.

Example

1import { SignalWire } from "@signalwire/realtime-api";
2
3const client = await SignalWire({ project: "ProjectID Here", token: "Token Here" })
4
5const voiceClient = client.voice;
6
7// Setup a voice client tolisten for incoming calls
8await voiceClient.listen({
9 topics: ['office'],
10 onCallReceived: async (call) => {
11 // Answer the call
12 console.log("Call received");
13 call.answer();
14 // Fax detection
15 await call.detectFax({
16 tone: 'CNG',
17 listen: {
18 onStarted: () => {
19 console.log("Fax detection started");
20 },
21 onUpdated: (event) => {
22 console.log("Fax detection updated:", event.result);
23 },
24 onEnded: (event) => {
25 console.log("Fax detection finished:", event.result);
26 call.hangup();
27 }
28 }
29 }).onStarted()
30 }
31})