Misc. Dialplan Tools play and get digits

From FreeSWITCH Wiki
Jump to: navigation, search



Play a prompt and get digits.


<min> <max> <tries> <timeout> <terminators> <file> <invalid_file> <var_name> <regexp> <digit_timeout> <transfer_on_failure>


  • min = Minimum number of digits to fetch (minimum value of 0)
  • max = Maximum number of digits to fetch (maximum value of 128)
  • tries = numbers of tries for the sound to play
  • timeout = Number of milliseconds to wait for a dialed response after the file playback ends and before PAGD does a retry.
  • terminators = digits used to end input if less than <max> digits have been pressed. (Typically '#')
  • file = Sound file to play while digits are fetched
  • invalid_file = Sound file to play when digits don't match the regexp
  • var_name = Channel variable into which digits should be placed
  • regexp = Regular expression to match digits
  • digit_timeout = Inter-digit timeout; number of milliseconds allowed between digits; once this number is reached, PAGD assumes that the caller has no more digits to dial
  • transfer_on_failure = where to transfer call when max tries has been reached, example: 1 XML hangup
    • Note: digit_timeout is optional and defaults to the value of <timeout>

Channel Variables

On exit, there may be some useful values in channel variables

  • read_terminator_used = The digit used to terminate entry (if a digit was used). Note that if termination was due to a timeout or hangup, then this channel variable is not touched (so may be left as nil or whatever it was on entry)


<extension name="play_and_get_digits example">
  <condition field="destination_number" expression="^(1888)$">
    <action application="play_and_get_digits" data="2 5 3 7000 # $${base_dir}/sounds/en/us/callie/conference/8000/conf-pin.wav /invalid.wav foobar \d+"/>
    <action application="log" data="CRIT ${foobar}"/>

This example demonstrates using say (or phrase) to get one digit after 3s, 250ms of silence on fail (no digit entered). Quote the text string!

<extension name="play_and_get_digits with say">
  <condition field="destination_number" expression="^(6500)$">
    <action application="play_and_get_digits" data="1 1 1 3000 # say:'press one for technicial support' silence_stream://250 res \d+" />

Note that the parameters are slightly different in the lua version (and you can't use "say"!)

       destnum = session:playAndGetDigits(3, 20, 3, 5000, "#*", "phrase:getnum", "phrase:error", "\\d+")
       terminator = session:getVariable("read_terminator_used")

See Also