Non-uniform behavior with Agi scripts


I’ve been trying to setup a simple Agi script, using Asterisk-Java, to play sounds and read DTMF digits. The script should work both for incoming and outgoing calls - to me, aparently, this doesn’t mean I have to change any script line as the methods are exactly the same in both situations. Anyway, the script logic is pretty basic.

However, as odd as its sounds, the scripts is only behaving correctly for incoming calls. That is, when I dial - from my home number to the SIP number provided. In this circunstances, the sound is played and the digits are gathered. In opposition, when I originate a call (with AMI) to my home number, it will reproduce the sound but WON’T collect any digit I press.

As it is playing music files, I reckon that the asterisk is receiving the commands as it should. Any idea of what could be causing this to malfunction?

Some considerations:

  • I’m using Skype For SIP to both receive and originate calls.
  • Also, I’m running the latest Asterisk version.
  • Asterisk is running on the cloud, could this be a network-related problem?

Does Asterisk see the DTMF events coming across the SIP channel? Or, are they just failing to hit the script for some reason?

Judging by the logs and verbose/debug output, there’s no notice of any DTMF events. I’ve been reading Asterisk’s documentation and this might be related to the dtmfmode SIP parameter. Unfortunately, my internet is performing badly right now and I’m losing most of the packets I send via AMI, so I’ll have to test it later.

If anyone has another opinion, I’d be glad to hear it.

Hello everybody,

Since my last reply, I’ve been able to test the system and tweak the DTMFmode setting as I wanted to. Using inband mode, instead of failing every time, the digits are being recognized some of the time. Note that it will still work as expected if I call to the sip number. This strange behavior only occurs when I originate a call to an outgoing number and execute the script as soon as the call is answered.

Sample debug:
---------- NOT WORKING --------------
<SIP/99051000XXXXXX-0000000b>AGI Rx << STREAM FILE “test” “0123456789”
– Playing ‘test’ (escape_digits=0123456789) (sample_offset 0)

---------- WORKING -------------------
<SIP/99051000XXXXXX-0000000d>AGI Tx >>
<SIP/99051000XXXXXX-0000000d>AGI Rx << STREAM FILE “test” “0123456789”
– Playing ‘test’ (escape_digits=0123456789) (sample_offset 0)
<SIP/99051000XXXXXX-0000000d>AGI Tx >> 200 result=49 endpos=30560

As you can see, it’s playing the sound normally in both cases but only the second one recognized the digit I pressed.