Answer the question
In order to leave comments, you need to log in
How to play an announcement using the Originate API?
Good afternoon!
At the moment I am working on the implementation of the "call back from the site" service using PHP and Asterisk.
The most common solution is to use the AMI and the Originate command.
In principle, the task is implemented by the Originate command via the API, specifying the required values
. Link to
the command description:
asterisk.ru/knowledgebase/Asterisk+Manager+API+Act... will make a call to the client. The Dial application has such an opportunity.
Tell me, how can I implement the playback of the announcement in this case in a simpler and more correct way?
I tend to use a variable in the form of a customer number and a Dial application with the A() option
Answer the question
In order to leave comments, you need to log in
Your solution didn't work.
Here is the right solution!
In PHP file:
$strChannel = "SIP/xxx"; // внутренний номер менеджера с которым будет происходить соединение
$strContext = "directoutbound"; //контекст исходящих звонков (у вас может быть и другой)
$strWaitTime = "30";
$strPriority = "1";
$strMaxRetry = "2";
$strExtenNonCanonical = $_POST['txtphonenumber']; //формирование номера из переменных
$trash = array("(", ")", "-", "");
$strreplace = array("", "", "", "");
$strExten = "10".str_replace($trash, $strreplace, $strExtenNonCanonical); //важный момент! Я добавил префикс 10 для корректной обработки в диалплане. Так как мой контекст обрабатывает все варианты исходящих звонков.
$length = strlen($strExten);
$strCallerId = preg_replace('/^10/', '', $strExten); //для корректного отображения callerid, я убрал префикс 10 из $strExten
if ($length >= 7 && is_numeric($strExten))
{
$oSocket = fsockopen($strHost, 12234, $errnum, $errdesc) or die("Connection to host failed");
fputs($oSocket, "Action: login\r\n");
fputs($oSocket, "Events: off\r\n");
fputs($oSocket, "Username: $strUser\r\n");
fputs($oSocket, "Secret: $strSecret\r\n\r\n");
fputs($oSocket, "Action: originate\r\n");
fputs($oSocket, "Channel: $strChannel\r\n");
fputs($oSocket, "WaitTime: $strWaitTime\r\n");
fputs($oSocket, "CallerId: $strCallerId\r\n");
fputs($oSocket, "Exten: $strExten\r\n");
fputs($oSocket, "Context: $strContext\r\n");
fputs($oSocket, "Priority: $strPriority\r\n\r\n");
fputs($oSocket, "Action: Logoff\r\n\r\n");
sleep (1);
fclose($oSocket);
?>
<p>
</p>
<?
;##### Обработка звонков с сайта #####
exten => _10ZXXXXXXXXXX,1,NoOp(webCalling)
same => n,Playback(webcall)
same => n,Dial(SIP/TR/${EXTEN:2},,T)
same => n,Hangup()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question