Telecom

Asterisk Dialplan: Introducing asterisk database (Latest Versions)

MYLINEHUB Team • 2026-02-10 • 9 min

Updated guide for modern Asterisk (PJSIP era): introducing asterisk database with real configs, common mistakes, and troubleshooting steps.

Asterisk Dialplan: Introducing asterisk database (Latest Versions)

Real-world Asterisk systems cannot rely only on static configuration files. Call routing decisions often depend on dynamic data: agent states, feature toggles, customer flags, callback markers, and more.

This is where the Asterisk internal database (AstDB) becomes useful. It provides a lightweight key–value storage system directly inside Asterisk, accessible from both the dialplan and CLI.

This guide introduces the Asterisk database in modern PJSIP-based deployments, explains how it works, and shows practical use cases used in production systems.

What Is the Asterisk Database (AstDB)?

AstDB is a built-in persistent key–value store used to save small pieces of runtime information.

  • Stored locally on the Asterisk server
  • Survives service restarts
  • Accessible via dialplan and CLI

It is not a full SQL database — but it is extremely fast and simple for telecom logic.

Where AstDB Data Is Stored

Default database file:

/var/lib/asterisk/astdb

Internally, Asterisk organizes keys in:

family/key = value

Viewing Database Entries from Asterisk CLI

asterisk -rvvv
database show

View a specific family:

database show agents

Adding Data to AstDB

From CLI

database put agents 1001 loggedin

Meaning:

  • Family → agents
  • Key → 1001
  • Value → loggedin

From Dialplan

Set(DB(agents/1001)=loggedin)

Reading Data from AstDB

exten => 600,1,NoOp(Agent status: ${DB(agents/1001)})

This allows dialplan logic based on stored state.

Deleting Data from AstDB

From CLI

database del agents 1001

From Dialplan

DBDel(agents/1001)

Common Real-World Uses of AstDB

  • Tracking agent login/logout state
  • Enabling or disabling call routing features
  • Storing callback requests
  • Marking VIP customers
  • Temporary call forwarding rules

These small runtime flags are perfect for AstDB.

Example — Agent Login Tracking with AstDB

; Agent login
exten => *45,1,Set(DB(agents/${CALLERID(num)})=online)
 same => n,Playback(agent-loginok)
 same => n,Hangup()

; Agent logout
exten => *46,1,DBDel(agents/${CALLERID(num)})
 same => n,Playback(agent-loggedoff)
 same => n,Hangup()

Example — Conditional Call Routing Using AstDB

exten => s,1,GotoIf($["${DB(vip/${CALLERID(num)})}"="yes"]?vip,1)

exten => vip,1,Playback(vip-customer)
 same => n,Queue(priority-support)
 same => n,Hangup()

This creates VIP routing logic without SQL or external systems.

AstDB vs External Databases (MySQL/PostgreSQL)

AstDB Is Best For

  • Small runtime flags
  • Fast lookup during calls
  • Simple state tracking

External Databases Are Best For

  • Customer records
  • Call history and reporting
  • Large datasets
  • CRM integration

Production telecom systems often use both together.

Common Problems and Fixes

DB Value Always Empty

  • Wrong family/key name
  • Value never stored

Changes Lost After Restart

  • Incorrect permissions on astdb file

Too Much Data in AstDB

  • AstDB is not designed for large storage

Best Practices for Using AstDB

  • Use clear family names (agents, vip, callbacks)
  • Store only small state values
  • Clean old keys periodically
  • Use external DB for analytics and CRM data

What Comes Next?

After understanding AstDB basics, the next step is learning how to:

  • Control queue membership using database state
  • Remove agents dynamically using AstDB flags
  • Build smarter dialplan automation

Key Takeaway

The Asterisk database (AstDB) is a simple but powerful tool for storing runtime telecom logic.

It enables dynamic call routing, agent state tracking, and feature control — all without external database complexity.

Try it

Want to see API-driven CRM + Telecom workflows in action? Try the WhatsApp bot or explore the demos.

💬 Try WhatsApp Bot ▶️ Watch CRM YouTube Demos
Tip: Comment “Try the bot” on our YouTube videos to see automation in action.
M
MYLINEHUB Team
Published: 2026-02-10
Quick feedback
Was this helpful? (Yes 0 • No 0)
Reaction

Comments (0)

Be the first to comment.