Calling curl script only on DTMF (INFO) package

Hello everyone!

I am looking for a way to call a .sh script whenever DMTF events on INFO are triggered during a SIP call.

Background:
I have an Asterisk (18.11.2) running in a Docker container (andrius/asterisk) and use it as a “man in the middle” between a SIP phone of mine and my main SIP trunk (a Fritz!Box) all in a local network. The Asterisk registers at the Fritzbox and the Phone with the Asterisk. That part is working perfectly fine, I can call with my phone others direcly registered at the Fritzbox. I also can log into the Asterisk and see the SIP messages. I see there for instance DTMF messages like this:

<— SIP read from UDP:192.168.178.1:5060 —>
INFO sip:asterisk@192.168.178.100:5060 SIP/2.0
Via: SIP/2.0/UDP 192.168.178.1:5060;branch=z9hG4bK21947B0E84F1D70F
From: sip:**612@192.168.178.1;tag=4E7822B219B982A9
To: “My SIP-Telefon” sip:asterisk@192.168.178.1;tag=as0afec484
Call-ID: 284d14a602a9415a553469e74e72e8b9@192.168.178.1
CSeq: 104 INFO
Contact: sip:C4630D92ECB0291FF09528B89D08542@192.168.178.1
Max-Forwards: 70
User-Agent: AVM FRITZ!Box
Supported: 100rel,replaces,timer,199
Allow-Events: telephone-event,refer
Content-Type: application/dtmf-relay
Content-Length: 24

Signal=2
Duration=100
<------------->
— (13 headers 2 lines) —
Receiving INFO!

  • DTMF-relay event received: 2

<— Transmitting (no NAT) to 192.168.178.1:5060 —>
SIP/2.0 200 OK
Via: SIP/2.0/UDP 192.168.178.1:5060;branch=z9hG4bK21947B0E84F1D70F;received=192. 168.178.1
From: sip:**612@192.168.178.1;tag=4E7822B219B982A9
To: “Mein SIP-Telefon” sip:asterisk@192.168.178.1;tag=as0afec484
Call-ID: 284d14a602a9415a553469e74e72e8b9@192.168.178.1
CSeq: 104 INFO
Server: Asterisk PBX 18.11.2
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLIS H, MESSAGE
Supported: replaces, timer
Content-Length: 0

Unfortunately I did not yet find any way on how to execute something if such a DTMF message is seen. I would be very happy for any help.

Content of my sip.conf:
[general]
allowguest=no
alwaysauthreject=yes
prematuremedia=no
progressinband=yes
dtmfmode=rfc2833

register => asterisk:verysecretpassword@192.168.178.1/asterisk

;register Asterisk with FritzBox
[asterisk]
type=friend
context=incoming_TIM_BS
allow=all
defaultuser=asterisk
fromuser=asterisk
fromdomain=192.168.178.1
secret=verysecretpassword
host=192.168.178.1
insecure=invite
qualify=yes

; register intern SIP-Telefon with Asterisk
[sipphone]
type=friend
host=dynamic
context=to-fritzbox
qualify=yes
secret=totalsecretpassword
dtmfmode=rfc2833
callerid=“My SIP-Telefon” <100>

Content of extentions.conf:
[incoming_TIM_BS]
exten => asterisk,1,NoOp()
same => n,GoTo(internal,1000,1)
same => n,Playtones(congestion)
same => n,hangup()

[to-fritzbox]
exten => _**612,1,NoOp(Starte AGI Skript)
same => n,AGI(/var/lib/asterisk/agi-bin/curl.sh)
same => n,Dial(SIP/${EXTEN}@asterisk)
same => n,Hangup()

The AGI-called script curl.sh contains exactly, what I want to be called, if a DTMF is seen. Currently it is called at the very start, once a call is established (for testing purposes).

I tried to change the dtmfmode, but regardless of what I put here, the DTMF is always send through the INFO package (I guess the phone simply do not care)

There is nothing built in, and you can not use AGI for that and do other things - it is not an event based solution. You could possibly write something that connected to the Asterisk Manager Interface and did it that way.

Thanks a lot for pointing me into the right direction! Activating the AMI and using NodeRed together with a special node (node-red-asterisk-ami-manager (node) - Node-RED) did the trick.