{"id":189,"date":"2016-06-30T07:34:41","date_gmt":"2016-06-30T07:34:41","guid":{"rendered":"http:\/\/symbioticindia.in\/docu\/?p=189"},"modified":"2016-06-30T07:34:41","modified_gmt":"2016-06-30T07:34:41","slug":"dtmf-to-file","status":"publish","type":"post","link":"http:\/\/symbioticindia.in\/docu\/2016\/06\/30\/dtmf-to-file\/","title":{"rendered":"DTMF to file"},"content":{"rendered":"<p>Here&#8217;s the source for a php\/agi file and dialplan sample I made, which can help you implement what you need :<\/p>\n<p>#extensions.conf<\/p>\n<p>exten =&gt; 12345,1,Goto(dtmf-recording,${EXTEN},1)<\/p>\n<p>[dtmf-recording]<br \/>\nexten =&gt; _X.,1,Answer<br \/>\nexten =&gt; _X.,2,Set(TIMEOUT(digits)=5)<br \/>\nexten =&gt; _X.,3,Set(TIMEOUT(response)=10)<br \/>\nexten =&gt; _X.,4,Set(TIMESTAMP=${STRFTIME(${EPOCH},,%Y%m%d-%H%M%S)})<br \/>\nexten =&gt; _X.,n,Read(DTMF|\/var\/lib\/asterisk\/agi-bin\/sounds\/whatever)<br \/>\nexten =&gt; _X.,n,Hangup<br \/>\nexten =&gt; h,1,Deadagi(agi-bin\/report_dtmf.php|${TIMESTAMP}|${DTMF})<\/p>\n<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<\/p>\n<p>report_dtmf.php :<\/p>\n<p>&lt;?php<br \/>\nset_time_limit(30);<br \/>\nrequire_once &#8220;phpagi.php&#8221;;<br \/>\ndeclare(ticks = 1);<br \/>\nob_implicit_flush(true);<\/p>\n<p>$AGI = new AGI();<br \/>\n$DSTDIR = &#8220;\/var\/lib\/asterisk\/agi-bin\/recordings\/&#8221;; \/\/Folder where you want to store the file.<br \/>\n$CALLERID = $AGI-&gt;request[&#8216;agi_callerid&#8217;];<br \/>\n$DATE = $_SERVER[&#8220;argv&#8221;][1];<br \/>\n$DTMF = $_SERVER[&#8220;argv&#8221;][2];<\/p>\n<p>$contents = &#8221;<br \/>\nCaller ID: $CALLERID<br \/>\nDTMF: $DTMF<br \/>\nDate: $DATE<br \/>\n&#8220;;<br \/>\n$fp = fopen($DSTDIR.$recfile.&#8217;.txt&#8217;, &#8216;w&#8217;);<br \/>\nfwrite($fp, $contents);<br \/>\nfclose($fp);<br \/>\n?&gt;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Here&#8217;s the source for a php\/agi file and dialplan sample I made, which can help you implement what you need : #extensions.conf exten =&gt; 12345,1,Goto(dtmf-recording,${EXTEN},1) [dtmf-recording] exten =&gt; _X.,1,Answer exten =&gt; _X.,2,Set(TIMEOUT(digits)=5) exten =&gt; _X.,3,Set(TIMEOUT(response)=10) exten =&gt; _X.,4,Set(TIMESTAMP=${STRFTIME(${EPOCH},,%Y%m%d-%H%M%S)}) exten =&gt; _X.,n,Read(DTMF|\/var\/lib\/asterisk\/agi-bin\/sounds\/whatever) exten =&gt; _X.,n,Hangup exten =&gt; h,1,Deadagi(agi-bin\/report_dtmf.php|${TIMESTAMP}|${DTMF}) &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; report_dtmf.php : &lt;?php set_time_limit(30); require_once &#8220;phpagi.php&#8221;; declare(ticks ..<\/p>\n<div class=\"clear-fix\"><\/div>\n<p><a href=\"http:\/\/symbioticindia.in\/docu\/2016\/06\/30\/dtmf-to-file\/\" title=\"read more...\">Read more<\/a><\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,25,23],"tags":[],"class_list":["post-189","post","type-post","status-publish","format-standard","hentry","category-asterisk","category-goautodial","category-vicidial"],"_links":{"self":[{"href":"http:\/\/symbioticindia.in\/docu\/wp-json\/wp\/v2\/posts\/189","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/symbioticindia.in\/docu\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/symbioticindia.in\/docu\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/symbioticindia.in\/docu\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"http:\/\/symbioticindia.in\/docu\/wp-json\/wp\/v2\/comments?post=189"}],"version-history":[{"count":1,"href":"http:\/\/symbioticindia.in\/docu\/wp-json\/wp\/v2\/posts\/189\/revisions"}],"predecessor-version":[{"id":190,"href":"http:\/\/symbioticindia.in\/docu\/wp-json\/wp\/v2\/posts\/189\/revisions\/190"}],"wp:attachment":[{"href":"http:\/\/symbioticindia.in\/docu\/wp-json\/wp\/v2\/media?parent=189"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/symbioticindia.in\/docu\/wp-json\/wp\/v2\/categories?post=189"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/symbioticindia.in\/docu\/wp-json\/wp\/v2\/tags?post=189"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}