promptAudio

View as MarkdownOpen in Claude

Play an audio file as the prompt, then collect DTMF or speech input. A typed convenience over playAndCollect().

Parameters

url
stringRequired

URL of the audio file to play as the prompt.

collect
CollectConfigRequired

Input collection configuration: digits, speech, initial_timeout, and the other fields accepted by playAndCollect(). Field names are the snake_case wire names; the object is sent as-is.

options
object

Playback options.

options.volume
number

Volume adjustment in dB, from -40 to 40.

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

Callback invoked when the operation reaches a terminal state.

Returns

Promise<CollectAction> — An action handle with stop(), pause(), resume(), volume(), startInputTimers(), 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.promptAudio(
'https://example.com/menu.mp3',
{ digits: { max: 1 } },
);
await action.wait();
});
await client.run();