I
I
Ivan Zhukov2014-09-05 17:05:49
PHP
Ivan Zhukov, 2014-09-05 17:05:49

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

2 answer(s)
I
Ivan Zhukov, 2014-09-08
@Bug87

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>
                              <?

In the dialplan:
;##### Обработка звонков с сайта #####
exten => _10ZXXXXXXXXXX,1,NoOp(webCalling)
 same => n,Playback(webcall)
 same => n,Dial(SIP/TR/${EXTEN:2},,T)
 same => n,Hangup()

This solution allows you to use a callback from several sites using different prefixes and flexibly manage the call in the dialplan.
I will not describe the HTML of the pop-up window. Here by yourself.

V
Vladimir, 2014-09-06
@rostel

You set the phrase in the Variable parameter Like
this:

Action: Originate
Channel: SIP/prov/89123456789
Context: test
Exten: anons
Priority: 1
Variable: anons=beep

In the dialplan:
[test]
exten => anons,1,Dial(SIP/100,15,A(${anons}))

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question