Skip to main content

Play & Get Input

The playGetInput() method in the PiopiyAction class allows you to play a media file during a call and capture user input via DTMF (Dual-Tone Multi-Frequency). This is useful in scenarios like interactive voice response (IVR) systems where callers are prompted to enter numbers.

playGetInput(url, audioFileOrUrl, options)
parameterTypeDescription
urlstringThe URL to send the DTMF input to
audioFileOrUrlstringThe URL or path to the audio file to be played
optionsObjectAn object containing optional parameters (max_digit & max_retry)
max_digitnumberMaximum number of digits expected from the user input
max_retrynumberNumber of retry attempts

Example Implementation

  • Here’s how to use the playGetInput() method to play an audio file and capture up to 3 digits of user input, with up to 2 retry attempts:
const { PiopiyAction } = require("piopiy");

const action = new PiopiyAction();

const options = { max_digit: 3, max_retry: 2 };

action.playGetInput( "https://example.com/webhook/dtmf", "https://example.com/your_audio_file.wav", options)