No matching results Documentation Forum
Asterisk Tutorial 26 - The Asterisk Database

Asterisk Tutorial 26 - The Asterisk Database

Introducing Asterisk Phone Systems – How to Use The Asterisk Database & Asterisk Functions

Over the next few tutorials we will be getting much more professional with our dynamic queues and dynamic members. However, as this is quite complicated, that does mean that we need to introduce a few new concepts starting with demonstrating how to add entries to the Asterisk Database and then using Asterisk functions with your dialplan to query the database.

What you need to know

First things first, it is important to understand that the Asterisk Database is a “Key Value” database, meaning that the “keys” are listed on the left and their corresponding “values” on the right. Moreover, the Asterisk Database is a persistent database, which means that when you stop your Asterisk service, a record of the database is stored and then recovered when Asterisk is restarted. This is particularly useful as it means you can copy the database to different Asterisk instances and create backups.

In order to access the Asterisk Database, simply log into the Asterisk CLI and use the command database followed by the appropriate command such as show. Additional commands can be see in the image below, however starting with the show command is a good idea as it provides you with an overview of existing entries within the Asterisk Database.

Asterisk phone system database

Adding Asterisk Database Entries

In order to add an entry to the Asterisk database, you will need to use the command database put and by pressing return you will get a read out of the syntax required to add your entry:

asterisk*CLI> database put
Usage: database put <family> <key> <value>
Adds or updates an entry in the Asterisk database for a given family, key, and value.

Therefore, to finish adding your entry to the database, use the command database put . In our example, this translates to:

database put pascom james ok. 

Once you are done, it is worth checking that everything worked correctly by using the database show command.

The family part of the string is an essential component of the database entry as it groups entries with similar characteristics together, thus providing an clearer database overview as well as making database management much simpler as highlighted when removing entries.

Removing Asterisk Database Entries

The role of the components of adding an entry become much clearer, when looking at removing entries. In order to remove an entry, two options are available. Firstly, to remove a single entry use the command database del . Should you wish to remove a whole family group you will need to use the database deltree command.

Introducing Asterisk Functions

Just like there being an application for everything within Asterisk, there is also a function for everything. In order to view all the available functions in Asterisk, use the command core show functions. For the purposes of this tutorial, we are interested in the function DB_EXISTS as this will allow us to get our dialplan to query if an agent can be found within the Asterisk Database or not, and therefore is already logged into the queue or not when building our dynamic queues.

In our test setup, we created a new extension in our dialplan, and then used the DB_EXISTS function as follows (${DB_EXISTS(family/key)}? followed by our new extension number plus actions concerning what the dailplan should do should the query return a true or false answer, as shown below:

exten => *300,1,NoOp(database test)
same => n,GotoIf(${DB_EXISTS(pascom/james)}?*300-ok,1)
same => n,Hangup

exten => *300-ok,1,NoOp(james exists)
same => n,Answer()
same => n,Playback(beep)
same => n,Hangup

So there you have it, how to use the Asterisk Database, add and remove entries as well as how to use functions to query the database. Next time we will take our dynamic queues even further, so stay tuned! Word to the wise, a very special event is coming up in the life of the VoIP Guys, which could mean we are off air for a short while, but rest assured we will be back very soon!

pascom hosted PBX - start upgrading your business communications today

Final Word

A well-configured business phone system that oozes useful tools, delivers excellent audio quality and intuitive call flows will leave callers with a highly professional impression. The configuration options, available applications and how well they are utilized will have a decisive impact on how professionally you manage your calls and therefore how your customers view your company. The switch to a pascom VoIP phone system solution provides the opportunity to not only upgrade your internal employee collaboration but also to redefine your business telephony.

If you would like more information regarding pascom and our Asterisk based PBX software, please visit our website or give the pascom team a call on +49 991 29691 0 to discuss your requirements and get started within minutes using our free hosted business VoIP phone system edition.

Thousands of companies trust pascom to stay connected

Logo - Amparex pascom Customer reference
Logo - KiKxxL pascom Call Centre Customer reference
Logo - Hotel Weitblick pascom Customer reference
Logo - Wake & Camp pascom Customer reference


Philipp Meixner, CEO
As a communications agency with just under 20 employees, the pascom phone system is perfect for us. The technical concept simply functions, which is what you want. The service is exceptional and always accessible (even if it is rarely needed) and as one of the agency’s business partners, we can only recommend pascom: open, straightforward, pleasant to work with - great. Thank you pascom!

Logo - Amparex pascom Customer reference


Stephan Förderung, CEO
We chose pascom because their phone systems offer a sleek, easy-to-use UC client and administration UI whilst providing us with all the PBX and UC features, control and visibility that we could need from our business communications solution. As a result of our excellent experience, we are happy to recommend pascom phone systems to all our customers.

Logo - KiKxxL pascom Call Centre Customer reference


Lars Hoeger, IT Director
When we make decisions regarding new systems, we want to make sure that we have both reins firmly in our hands. Therefore, it is essential to implement systems which adhere to OpenStandards, allowing us to seamlessly connect and integrate these into our existing systems. In addition, we require reliable suppliers, who are ready to customise their solutions to our requirements, which is why we chose pascom who offer exactly this service and more.

Logo - Hotel Weitblick pascom Customer reference


Kassandra Martin, Deputy Director & Reception Manager
We chose pascom as our telephony solution in part due to the scalability, flexibility and ease of deployment. In addition, the pascom platform functions perfectly with our digital guest directories in our rooms whilst offering the largest range of features at easily the most cost effective price compared to alternative solutions. A further deciding factor was the wide choice of compatible hardware that choosing pascom afforded us.

Logo - Wake & Camp pascom Customer reference

Wake & Camp Ruhlsdorf

Markus Gerlitzki, Managing Director
My team and I pride ourselves on the level of excellent care we provide our guests. However, it can be distracting when the phone is always ringing and we constantly answer the same questions. Thanks to the pascom phone system, we have been able to set up an automated attendant self-service hotline which allows guests to quickly get answers and if required callers can be quickly and efficiently routed to an employee. The system greatly improves customer service with around-the-clock answers around opening times and courses and therefore reduces the strain on employees, ensuring we are free to cater to the needs of our on-site guests.

Back to the top