Asterisk, Ignore DTMF special characters in GET DATA

787 Views Asked by At

I'm using phpagi $agi->get_data to read digit from user.
In some telephones, user didn't hit any key, but audio playback immediately stops and get result of "D" !!
I searched a lot about it, and looks like $agi-get_dat receives DTMF data that contains 0-9*#ABCD.
1st question is, why my users get "D" without hitting any key!
2nd question is, how can i ignore these characters to prevent interrupting my ivr.

2

There are 2 best solutions below

2
arheops On

phpagi getdata do this call

https://wiki.asterisk.org/wiki/display/AST/AGICommand_stream+file

so you can extend it by adding allowed digits param. PhpAGI lib is opensource and have source code.

Actualy you can just use stream_file call

stream_file (line 677)

Play the given audio file, allowing playback to be interrupted by a DTMF digit. This command is similar to the GET DATA command but this command returns after the first DTMF digit has been pressed while GET DATA can accumulated any number of digits before returning.

return: see evaluate for return information. ['result'] is -1 on hangup or error, 0 if playback completes with no digit received,

otherwise a decimal value of the DTMF tone. Use chr() to convert to ASCII. link: http://www.voip-info.org/wiki-stream+file example: Ping an IP address

array, stream_file (string $filename, [string $escape_digits = ''], integer $offset)

string $filename: without extension, often in /var/lib/asterisk/sounds    
string $escape_digits 
integer $offset
0
iman tavakoli On

you can check the logs by the following command :

asterisk -vvvvv

and you can check the value of the input for example in php code :

$val = $agi->get_data exec("echo $val >> /tmp/output")

and then check this file : /tmp/output