Perform a web look up from Asterisk dial plan? - asterisk

I have a text file that I would like to access and use in a dial plan. What is the syntax for accessing the file from within the dial plan?
Something like:
Dial(tech/service/[http://textfile])

Since it seems you have already made the file accessible from a web server you can use the asterisk curl function :
You'll probably need to recompile asterisk after installing the curl dev libraries,
http://www.voip-info.org/wiki/index.php?page=Asterisk+func+curl
Then you can :
exten => s,1,Set(dest=${CURL(http://textfile)})
exten => s,2,Dial(SIP/${dest})

You can try to create an AGI script (in PHP, C, Java whatever language) and call that from the dialplan:
exten => _x,n,AGI(your-script.php)
You can then do all sorts of stuff in that script. If you can provide more details of what you're trying to do, guys on StackOverflow can probably guide you better.

Related

Deleting FreePBX Speed Dials

Using freePBX 15.
From a phone, I entered *75 ( Asterisk Speed Dial entry "star code" )
and a speed dial label and code. This was just for a test.
Now, I want to delete it, but haven't found any way to do this.
I checked the Asterisk Phonebook for my entry, but it wasn't there.
To delete speeddial you should manually remove asterisk database entry key AMPUSER/${AMPUSER}/speeddials/${entry}
Here is part of code which set it.
exten => s,n(success),Set(DB(AMPUSER/${AMPUSER}/speeddials/${newlocation})=${newnum})
No, you have no option for do that via dialplan, but you always welcome to make changed module.
For more info about database see this
https://wiki.asterisk.org/wiki/display/AST/Asterisk+Internal+Database

Adding a prefix in outgoing calls in Asterisk

We have a many services in our company, each one must display a different number in his outgoing calls. We use a Asterisk SIP server.
Our SIP provider asks us to make our Asterisk server send a prefix before the outgoing number.
for exemple, for a normal call from the extension 1200, the SIP server send the number 0033123456789.
we want to make it adding a prefix for calls from each extension, for exemple :
add the prefix 400 before calls from the extension 1200 to send 40033123456789.
add the prefix 401 before calls from the extension 1201 to send 40133123456789.
... etc.
Can you help please ?
Many thanks.
Regards.
There might be several ways to achieve what you need, if calls from all extensions hit same context(context start with [some-context-name]), then you might achieve it in following way:
[some-context-name]
exten => _00X.,1,ExecIf($["${CALLERID(num)}" = "1200"]?Dial(SIP/mytrunk/400${EXTEN:2}))
exten => _00X.,1,ExecIf($["${CALLERID(num)}" = "1201"]?Dial(SIP/mytrunk/401${EXTEN:2}))
Additionally you might have separate context per extension or you might implement all of this inside AGI script.

FreePBX add a new SIP extension

I've successfully built VoIP server with FreePBX Asterisk. It works fine when I register a user on FreePBX. However, I would like to register a SIP account from mobile device directly. I found out that I can add custom information into FreePBX MySQL database.
However, it doesn't work either, and I couldn't find a place to insert SIP password.. Someone said that I need to do something with /var/www/html/admin/functions.inc.php file. Is there better way to create a new SIP extension from outside of FreePBX GUI? Thank you.
Freepbx not use database way(asterisk realtime).
Instead it use text file method.
After adding new info into mysql database, you have apply changes on web to write new config files. You can do same from command line interface (see amp_engine), but can't do that using db query.
Other option is use freepbx framework.php correctly.
Also you can use asterisk realtime architecture and not use freepbx dialplan.
WARNING Freepbx is designed for low number of extensions and low load(branch office pbx). As result using it for support mobile device application will be great fail. Check other projects, for example a2billing.org or hire expert to build core server with HA/failover for your need.

Asterisk and A2billing

I am trying to configure asterisk to work with a2billing.
I need a prepaid billing system for the extensions provisioned
on my system, so I will only be billing extension to extension calls for now.
I cannot seem to find any comprehensive tutorial that does this(i.e without outside connectivity billing).
Any help would be appreciated.
You need setup context like this in /etc/asterisk/extensions.conf:
[a2billing]
exten => _X.,1,AGI(a2billing.php,1)
After that in agi-conf1 you need set use-dnid=yes, number-try=1, play-audio=no
And assign to your extension accountcode=username(pin) in a2billing and context=a2billing
After that you can call ext2ext using 5555 prefix(default).
Or you can use context
[exts]
exten => _X.,1,Set(CDR(DNID)=5555${EXTEN})
exten => _X.,2,Goto(a2billing,5555${EXTEN},1)

Delete dial rule in Asterisk via AMI

I'm running Asterisk 11.4.0, and I've got access to it via AMI.
I've got a line like this in my [default] context in extensions.conf.
exten => 12345,1,Dial(SIP/${EXTEN}#0041905093,30,r)
So, i have mask (12345) and I need to delete a dial rule, belonging to the mask.
How can I do this?
I managed to do this:
If you want to remove extension A from context B, you need write CLI command (using "action" = "command") like this:
dialplan remove extension A#B

Resources