Contact

Blogs

Take a look at the things that interest us.

Asterisk realtime mysql extensions

Wesley Wesley 2 years
Asterisk realtime mysql extensions

In this tutorial, we are going to setup a real-time extension connection for our Asterisk 18 and MySQL database.

Requirements

  • Asterisk 18
  • ODBC connection

Mysql Database

To get started with our real-time extensions, we'll first need to add the extension table to our database.

CREATE TABLE IF NOT EXISTS `extensions` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `context` varchar(40) NOT NULL,
  `exten` varchar(40) NOT NULL,
  `priority` int(11) NOT NULL,
  `app` varchar(40) NOT NULL,
  `appdata` varchar(256) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `context` (`context`,`exten`,`priority`),
  UNIQUE KEY `id` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

The table explains as follow:

  • 「context」 — The context of the dialplan.
  • 「exten」 — The extension number a call comes from.
  • 「priority」 — The priority of the current row.
  • 「app」 — The app function.
  • 「appdata」 — The app data.

Now let's add some test data to this table.

INSERT INTO extensions
(context, exten, priority, app, appdata)
VALUES 
('mycontext', '_1XX', 1,'Dial', 'PJSIP/${EXTEN},60,tT');

We use this data at a later time to make our first real-time extension call.

Asterisk 18

To make the extension table work we need to update a few files in our Asterisk directory. Let move to the asterisk directory.

$ cd /etc/asterisk

Open the extconf file.

$ vim extconf.conf

Add the following line to your config file.

extensions => odbc,asterisk

Now open your extension config file.

$ vim /extensions.conf

Add the following line

[mycontext]
switch => Realtime/mycontext@extensions

// for every new context, you'll add a new line to your extension config

You are finished setting up your real-time extension table. Now restart your Asterisk to make the new system work.

$ systemctl restart asterisk

You are now able to make calls through your extension table.

Asterisk realtime mysql extensions 2021-08-18 10:20:32

There are no comments.

4682

Have questions about our services?

Contact our Sales team to get answers.

Contact Us
gomibako@aska-ltd.jp