detectDigit

View as MarkdownOpen in Claude

Detect DTMF digits on the call. A typed convenience over detect() with the digit detector.

Parameters

options
object

Detector options.

options.digits
string

The digits to listen for, such as "0123456789#*".

options.timeout
number

Maximum seconds to run the detector before stopping.

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

Callback invoked when the operation reaches a terminal state.

Returns

Promise<DetectAction> — An action handle with stop() and wait() methods. It resolves on the first detection result.

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.detectDigit({ digits: '0#', timeout: 15 });
const event = await action.wait();
console.log(event.params);
});
await client.run();