Deleting FreePBX Speed Dials - asterisk

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

Related

Pulling only Registration Contact information on Asterisk

I am not using real-time asterisk , But still astdb.sqlite3 contains entries of online peers with Reg.Contact information in SIP/registry/peer. key . I would like to store contact information of all peers as they come online in a separate persistent database. I need this for sending push notifications by fetching deviceID etc information in registration contact .
I tried to pull this information from astdb.sqlite3 but the entries are clearing off as soon as devices go offline .Though I am able to fetch the information with "sip show peer XXXX" in asterisk CLI , It is overburdened to fetch every time like this . Instead I want to save only Regcontact information for all the devices in a database ( without realtime) as the devices come online. The other way I tried to pull the information is using AMI event listener. But with AMI I don't see complete information like contact information It displays only below information
Event: PeerStatus
Privilege: system,all
SequenceNumber: 75
File: manager.c
Line: 1856
Func: manager_default_msg_cb
ChannelType: SIP
Peer: SIP/2030
PeerStatus: Reachable
Can someone suggest a better way to push Only Regcontact information to a database as the devices come online .
There are no mechanism like that in asterisk.
You can use kamailio or write patch similar to this one https://reviewboard.asterisk.org/r/4490/
It sounds like you have dynamic IPs for your endpoints, and you want a way to update a separate DB as soon as a device registers with an IP/port pair.
If you enable the security log, you will see all auth events, including the "SuccessfulAuth" event, which includes the RemoteAddress of the endpoint (including port and protocol).
Here is an example line:
[Jul 21 19:53:45] SECURITY[1342] res_security_log.c: SecurityEvent="SuccessfulAuth",EventTV="2020-07-21T19:53:45.182+0000",Severity="Informational",Service="SIP",EventVersion="1",AccountID="102",SessionID="0x7f41040132c0",LocalAddress="IPV4/UDP/10.0.0.200/5060",RemoteAddress="IPV4/UDP/10.0.0.75/5062",UsingPassword="1"
If all you're looking for is AccountID="102" and RemoteAddress="IPV4/UDP/10.0.0.75/5062", a very fast/cheap way to get it is to enable the security log, and use a script to tail it and update your DB as soon as the event occurs. I like to keep the security log on anyways for utilities like fail2ban. Just make sure your script is able to reopen the file each time it is rotated.
Edit:
By default the log is in /var/log/asterisk. To enable it, edit /etc/asterisk/logger.conf and un-comment (or create) the line under [logfiles] that says security => security.

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.

Setting a Dialplan for guests?

I am trying to configure my asterisk to regsiter every user who tries to connect to it, and allow it to establish calls. I have read that I should set "allowguest = yes" in sip.conf.
What about the dialplan in extensions.conf ? What should I add so that all my users could make and recieve calls ? (this is my first questions).
I would go even more precise about the users : is it possible to allow only guests from one precise domain ? If yes please help find how to do it, I will be very thankful.
Guest calls will go to default context which is in general section of sip.conf
[general]
context=some_restricted_access
About dialplan for calls - you need read some book for beginner or install freepbx/other web which do dialplan for you.
No, you can't allow guests from domain. But you can try play with realm= setting or allow access from one ip by using ip-authentification.

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.

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