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)
parameter | Type | Description |
---|---|---|
url | string | The URL to send the DTMF input to |
audioFileOrUrl | string | The URL or path to the audio file to be played |
options | Object | An object containing optional parameters (max_digit & max_retry) |
max_digit | number | Maximum number of digits expected from the user input |
max_retry | number | Number 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:
- Node.js
- Python
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)
from piopiy import Action
# Create an instance of the Action class
action = Action()
options = { "max_digit": 3, "max_retry": 2 }
action.playGetInput("https://example.com/webhook/dtmf", "https://example.com/your_audio_file.wav", options)