SendDTMF in a .call file?

The Short Version:

I’ve been reading about SendDTMF, but it looks like it’s used in dialplans only, I was wondering if there was a way to send DTMF in a call file?

The Longer Version w/ some background.

This might seem like a weird question, but we’re using a bash script to monitor our Asterisk installation and send the results to our Zabbix server. Right now I’ve put together:


DATE=date +%d%m%Y-%H%M

echo “Channel: Local/1234567890@from-internal” >> /tmp/$FILENAME
echo “Application: Playback” >> /tmp/$FILENAME
echo “Data: hello-world” >> /tmp/$FILENAME
echo “MaxRetries: 2” >> /tmp/$FILENAME
echo “RetryTime: 30” >> /tmp/$FILENAME
echo “Priority: 1” >> /tmp/$FILENAME
echo “Archive: Yes” >> /tmp/$FILENAME
chmod 777 /tmp/$FILENAME
mv /tmp/$FILENAME /var/spool/asterisk/outgoing/
sleep 10
STATUS=cat /var/spool/asterisk/outgoing_done/$FILENAME |grep Status:|awk '{print $2}'
/etc/zabbix/./zabbix_sender -z 192.168.0.## -p [port] -s [hostname] -k asterisk.testcallout -o $STATUS

This creates a test call to 1234567890 from our main line, plays back hello-world and then reports whether that call Completed, Expired, or Failed to the Zabbix server.

I’ve been asked to make another script that will call out from our Asterisk server into one of our other phone numbers on the same Asterisk server and verify that we’re able to accept incoming calls as well as make sure that they’re clear.

If there’s a simpler way to accomplish the previous requirement we’d love to hear about it is, but our thinking is modify the previous script to place a call to one of our phone numbers on the same asterisk server, have the server pick up the other line and monitor it for the proper DTMF sequence.


DATE=date +%d%m%Y-%H%M

echo “Channel: Local/18001234567@from-internal” >> /tmp/$FILENAME
echo "[Insert DTMF Command Here]"
echo “MaxRetries: 2” >> /tmp/$FILENAME
echo “RetryTime: 30” >> /tmp/$FILENAME
echo “Priority: 1” >> /tmp/$FILENAME
echo “Archive: Yes” >> /tmp/$FILENAME
chmod 777 /tmp/$FILENAME
mv /tmp/$FILENAME /var/spool/asterisk/outgoing/

[Insert Monitoring Command(s) Here]

sleep [However long necessary to make sure the test has complete]

CALLSTATUS=[Wherever we would pull whether the call status from]
CALLCLARITY=[Wherever we would pull whether the call clarity from]

Might be able to just use stdout from the previous command(s)

/etc/zabbix/./zabbix_sender -z 192.168.0.## -p [port] -s [hostname] -k asterisk.testcallinstatus -o $CALLSTATUS
/etc/zabbix/./zabbix_sender -z 192.168.0.## -p [port] -s [hostname] -k asterisk.testcallinclarity -o $CALLCLARITY

Maybe you can try to send the call file to extension which execute an PHPAGI (or from the same call file). In your PHPAGI file you can try to use the application exec with sendtmf.

Would you mind expanding on that a bit? I’ve been trying to find a bit more information regarding the AGI, from what I’ve gathered I’ll probably need to write two seperate AGI scripts in order to get this working how we want it to.

One that would call out and wait until the line was picked up then proceed to send the DTMF and hangup.

I’m trying to get my feet wet and just start with something basic. So I put this hello-world.php that I found here in /var/lib/asterisk/agi-bin/hello-world.php It looks like it should play the tt-monkeys file when the call is answered.

 #!/usr/local/bin/php -q

  $agi = new AGI();


  // Play the hello-world file from /var/lib/asterisk/sounds


I tried using my previous batch file modified slightly to try to get it to call that agi script.


DATE=`date +%d%m%Y-%H%M`
echo "Channel: Local/1234567890@from-internal" >> /tmp/$FILENAME
echo "Application: AGI" >> /tmp/$FILENAME
echo "Data: hello-world.php" >> /tmp/$FILENAME
echo "MaxRetries: 2" >> /tmp/$FILENAME
echo "RetryTime: 30" >> /tmp/$FILENAME
echo "Priority: 1" >> /tmp/$FILENAME
echo "Archive: Yes" >> /tmp/$FILENAME
chmod 777 /tmp/$FILENAME
mv /tmp/$FILENAME /var/spool/asterisk/outgoing/

This does successfully call 1234567890 but it immediately hangs up rather than playing the hello-world file locate in /var/lib/asterisk/sounds/. I’m trying to figure out what I missed and am a bit frustrated because any documentation I can find seems to be very old and fragmented. If you could point me in the right direction or offer some hints I’d greatly appreciate it.


Why not use a local channel.

we use this with nagios for testing connectivty

basicly on server A a cron job moves a call file

this calls a Local channel number that then dials server B waits enters a DTMF stream thats accepted by B , Bresponds with a reply DTMF stream and all is recorded in a logfile that nagios checks.


A Basic example:

Call file:

Channel: Local/9876@music MaxRetries: 0 RetryTime: 15 WaitTime: 15 Application: AGI Data: test.agi

Agi file:

[code]#!/usr/bin/php -q

<?php ini_set('display_errors', 1); set_time_limit(30); require('phpagi/phpagi.php'); error_reporting(E_ALL); $agi = new AGI(); $agi->answer(); $agi->verbose("antes del dtmf",3); $agi-> exec("sendDTMF","w987#"); $agi->verbose("despues del dtmf",3); $agi->exec("echo",""); // $agi->hangup(); ?>


somewhere in extensions.conf:

[music] exten => 9876,1,Answer() same => n,Authenticate(987) same => n,playback(tt-monkeys) same => n,hangup()

Basically the call file executes the AGI cmd in the 9876@music and send the dtmf commands an wait for echo in this case tt-mokeys sounds.

That sounds exactly like what I’m trying to do, is the log file that you speak of the /var/spool/outgoing_done? or are you monitoring something else?