Answer the question
In order to leave comments, you need to log in
Asterisk AGI, checking order status by entering customer DTMF numbers. How to implement?
Hello, you need to implement checking the status of the caller's order by entering the order number from the phone in tone mode , i.e. so that the answer is ready \ not ready \ completed.
Now it is done in such a way that the caller's number is taken, checked against the database and the result is given, but unfortunately it does not quite fit, although it is more convenient for the client. At a minimum, the client may have several orders, or he may call from another number.
Number identification option:
;Вызваем php скрипт check_status.php с аргументом номер клиента.
exten => s,n,AGI(check_status.php, ${CALLERID(number)})
<?php
//check_status.php скрипт для автоматического ответа по статусу заказа
//Подключаемся к базе данных (причем, можно отметить, что php имеет в своем наборе интерфейсы
//практически ко всем типам баз данных которые только существуют)
$conn = mysql_connect("localhost", "mysql_user", "mysql_password");
mysql_select_db("clients");
//Делаем выборку по номеру клиента
$sql = "SELECT status
FROM clients
WHERE client_number = ".$argv[1];
$result = mysql_query($sql);
$row = mysql_fetch_assoc($result);
// Получили статус предположим что они бывают Ready и Please_Wait
$status=$row["status"];
mysql_free_result($result);
//Подключаем класс для работы с Asterisk
require('phpagi.php');
$agi = new AGI();
//Отвечаем на вызов клиента
$agi->answer();
// Проигрываем заранее заготовленные файлы Ready или Please_Wait /var/lib/asterisk/sounds
$agi->stream_file($status);
$agi->hangup();
?>
Answer the question
In order to leave comments, you need to log in
You can get DTMF from the client something like this:
$sound = 'enter_digits_and_press_#'; //файл со звуковым сообщением
$timeout = 20000; //таймаут для ввода DTMF - 20 секунд (в миллисекундах)
$max_dtmf_input = 10; //разрешить максимум 10 символов DTMF
$dtmf = $agi->get_data($sound, $timeout, $max_dtmf_input);
$code = $dtmf['result']; //строка с введенными цифрами
I would consider DTMF before calling AGI using Asterisk
exten => s,n,DigitTimeout(4)
exten => s,n,ResponseTimeout(5)
exten => s,n,Read(code,say-enter-dtmf-code,10)
exten => s,n,AGI(check_status.php, ${code})
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question