There are always more than one way to do anything in asterisk.
The method I use is basically creating a extension in extensions.conf within the same context as your phonepatch (autopathup) is in that looks like this
[my-pbxip]
exten=00,1,Set(MYADDR=${CURL(https://api.ipify.org?format=json)})
exten=00,2,Wait,3
exten=00,3,SayAlpha(${MYADDR})
exten=00,n,Hangup
You could create a new phone patch command and specify a NEW context that is the stanza name in this case [my-pbxip]
69=autopatchup,context=my-pbxip,noct=1,farenddisconnect=1,dialtime=9000,quiet=1
So, using it in this way, you would dial *6900 to fetch and playback the ext ip of your server
So, that’s a skinny way to do this effectively with 6 lines of text.
I actually use one entry in extensions.conf and use a gosub/goto to that from many contexts I use in the system. Including my sip-phones. This keeps me from re-writting in many places if something changes.
On occasion, the web address you use to extract the info will change or go down permanently, but some other ones are out there. They just need to output in a single text line from a single curl hit.
The one pointed to in my example I have been using for about 4 years now I think. Never a issue but It’s not all that often I use it. Probably more in script use than anything else.
Since I really do not know if a current install of ASL-Asterisk contains ‘curl’ you may need to install it
sudo apt-get install curl
It’s small and useful for a lot of things in the system
Edit:
So I forgot the startup option…
So, you have a option for a start-up macro in rpt.conf
You can issue the dtmf string in that startup macro.
See the wiki.
https://wiki.allstarlink.org/wiki/Rpt.conf#startup_macro.3D