Thursday, September 5, 2019

Modify Asterisk Queue members via SQL

It is possible to add static agents to a queue via a SQL statement.
Here you see the static members of a queue 
https://imgur.com/a/vzEgDLv
In the table "queues_details" in the database "asterisk" this select will show you all your configured queues.
MariaDB [asterisk]> select * from queues_details;
+------+-----------------------------+---------------------------+-------+
| id   | keyword                     | data                      | flags |
+------+-----------------------------+---------------------------+-------+
| 2001 | member                      | Local/1005@from-queue/n,0 |     3 |
| 2001 | member                      | Local/1006@from-queue/n,0 |     4 |
| 2001 | member                      | Local/1004@from-queue/n,0 |     2 |
| 2001 | member                      | Local/1002@from-queue/n,0 |     1 |
| 2001 | member                      | Local/1001@from-queue/n,0 |     0 |
| 2001 | answered_elsewhere          | 0                         |     0 |
| 2001 | penaltymemberslimit         | 0                         |     0 |
| 2001 | timeoutpriority             | app                       |     0 |
My example shows Queue (ID) 2001 with static members 1001-1006 (1003 is missing)
You can add a member (which will show up in the GUI if you edit it too) using this command. I'm adding extension "1003" into queue 2001.
MariaDB [asterisk]> insert into `queues_details` (`id`,`keyword`,`data`,`flags`) values (2001,'member','Local/1003@from-queue/n,0',100);
Query OK, 1 row affected (0.00 sec)

MariaDB [asterisk]> select * from queues_details;
+------+-----------------------------+---------------------------+-------+
| id   | keyword                     | data                      | flags |
+------+-----------------------------+---------------------------+-------+
| 2001 | member                      | Local/1005@from-queue/n,0 |     3 |
| 2001 | member                      | Local/1006@from-queue/n,0 |     4 |
| 2001 | member                      | Local/1004@from-queue/n,0 |     2 |
| 2001 | member                      | Local/1002@from-queue/n,0 |     1 |
| 2001 | member                      | Local/1001@from-queue/n,0 |     0 |
| 2001 | answered_elsewhere          | 0                         |     0 |
| 2001 | maxlen                      | 0                         |     0 |
| 2001 | member                      | Local/1003@from-queue/n,0 |   100 |
+------+-----------------------------+---------------------------+-------+
42 rows in set (0.00 sec)
What you have to do is set the "FLAG" value to a high value (higher than any current) when you enter it, and you have increment it. My example uses 100.
If you look in the GUI, you'll see it shows up there as well now.

No comments:

Post a Comment