Answer the question
In order to leave comments, you need to log in
How to determine the region of the caller in Asterisk?
Good time, tell me, there is a desire to launch 8-800 ..... but since we are located in different regions of the country, I want to automatically direct incoming calls to the region where customers are located. Who faced?
Answer the question
In order to leave comments, you need to log in
First, download the code base:
wget -N www.rossvyaz.ru/docs/articles/DEF-9x.html
wget -N www.rossvyaz.ru/docs/articles/ABC-3x.html
wget -N www.rossvyaz.ru /docs/articles/ABC-4x.html
wget -N www.rossvyaz.ru/docs/articles/ABC-8x.html
CREATE TABLE `abcdef` (
`def` smallint(6) NOT NULL,
`start` int(11) NOT NULL,
`finish` int(11) NOT NULL,
`count` int(11) NOT NULL,
`operator` varchar(64) NOT NULL DEFAULT '',
`region` varchar(128) NOT NULL DEFAULT '',
`region_last` varchar(64) DEFAULT NULL,
`region_first` varchar(64) DEFAULT NULL,
KEY `a_b` (`def`,`start`),
KEY `a` (`def`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE DEFINER=`root`@`localhost` FUNCTION `abcdef_region`(n char(10)) RETURNS varchar(64) CHARSET utf8
BEGIN
DECLARE l VARCHAR(3);
DECLARE r VARCHAR(7);
DECLARE tmp VARCHAR(64);
DECLARE tmp2 VARCHAR(64);
DECLARE i INT;
SET l=LEFT(n, 3);
SET r=RIGHT(n, 7);
SELECT region_last INTO tmp FROM abcdef where `def`=l and `start`<=r and `finish`>=r;
IF (length(TRIM(tmp))=0 OR tmp like NULL) THEN
SET tmp='---';
END IF;
RETURN tmp;
END
func_odbc.conf:
[CALLREGION]
dsn=MySQL_asterisk_utf8
readsql=SELECT abcdef_region('${SQL_ESC(${ARG1})}');
NoOp(${ODBC_CALLREGION(${CALLERID(num)})});
Well, look at the prefix and, depending on this, direct.
${CALLERID(num):1:4} is probably good enough to check the prefix, and then route to the desired extension, tied to the region.
You can put region prefixes in the base and identify them with specific endpoints. Make a selection from the database in dialplan, and then route as you want.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question