Vanessa,

Segue abaixo um script que uso.

Ps: Como fiz alguns ajustes retirando coisas aqui da empresa do script pode ser que tenha alguns ajuste ou erro a se corrigir, mas ja serve como base.


Para maiores informações consultar: http://www.voip-info.org/wiki/view/Asterisk+auto-dial+out


Extensions.conf

exten = _X.,1,AGI(callback.php)


#!/usr/bin/php -q

<?php

/*

|--------------------------------------------------------------------------

| READ-ME

|--------------------------------------------------------------------------

| Salve este conteúdo em /var/lib/asterisk/agi-bin/callback.php

|

| Antes de executar este script será necessário instalar e habilitar as 
bibliotecas

|

| apt-get install -y php-http php5-dev libcurl3 libpcre3-dev 
libcurl4-openssl-dev

|

| Copiar a biblioteca PHPAGI disponível em (http://phpagi.sourceforge.net/)

| no diretório /var/lib/asterisk/agi-bin/phpagi-2.20

*/

require_once __DIR__.'/phpagi-2.20/phpagi.php';

openlog(pathinfo(__FILE__)['basename'], LOG_PID | LOG_PERROR, LOG_LOCAL0);

try{

        $agi = new AGI();

        $agi->exec('VERBOSE','"Entrada da CallBack" 4');

        $caller = '';

        $exten = '';

        $channel = '';

        $outputContext = 'saida';

        $forwardTo = '1000';

        $uniqueId = $agi->request['agi_uniqueid'];

        if ((isset($agi->request['agi_callerid'])) && 
($agi->request['agi_callerid'] != ''))

                $caller = $agi->request['agi_callerid'];

        if ((isset($agi->request['agi_extension'])) && 
($agi->request['agi_extension'] != ''))

                $exten = $agi->request['agi_extension'];

        if ((isset($agi->request['agi_channel'])) && 
($agi->request['agi_channel'] != ''))

                $channel = $agi->request['agi_channel'];

        if (empty($caller) || empty($exten) || empty($channel) || 
(strlen($channel) < 2))

        {

                $agi->exec('VERBOSE','"CallerID, Channel ou Exten não 
fornecidos" 3');

                die();

        }

        $cId = 'cb-' . date('U') . '-' . $caller;

        $filename = 'call_'.$cId.'.call';

        if (strlen($cId) > 19)

                $cId = substr($cId,0,19);

        try{

                $myfile = fopen("/tmp/{$filename}", "w");

        } catch (Exception $e) {

                throw new Exception("Falha abrindo o arquivo de ligação");

        }

        $txt = "Channel: Local/".$caller."@".$outputContext."\n";

        fwrite($myfile, $txt);

        $txt = "Context: ".$outputContext."\n";

        fwrite($myfile, $txt);

        $txt = "Extension: ".$forwardTo."\n";

        fwrite($myfile, $txt);

        $txt = "Priority: 1\n";

        fwrite($myfile, $txt);

        $txt = "CallerID: <$caller>\n";

        fwrite($myfile, $txt);

        $txt = "Codecs: gsm,alaw,ulaw\n";

        fwrite($myfile, $txt);

        $txt = "MaxRetries: 3\n";

        fwrite($myfile, $txt);

        $txt = "RetryTime: 45\n";

        fwrite($myfile, $txt);

        $txt = "WaitTime: 90\n";

        fwrite($myfile, $txt);

        $txt = "Account: $cId\n";

        fwrite($myfile, $txt);

        $txt = "Archive: yes\n";

        fwrite($myfile, $txt);

        $txt = "SetVar: CHANNEL(language)=pt_BR\n";

        fwrite($myfile, $txt);

        $txt = "SetVar: CDR(userfield)=$cId\n";

        fwrite($myfile, $txt);

        fclose($myfile);

        try{

                exec('touch -d "$(date -r /tmp/'.$filename.') + 20 seconds" 
"/tmp/'.$filename.'"');

        } catch (Exception $e) {}

        exec('sudo chmod 777 /tmp/'.$filename.'; sudo mv /tmp/'.$filename.' 
/var/spool/asterisk/outgoing/');

        //Antende a chamada

        $agi->answer();

        sleep(1);

        //Reset o CDR, para no relatório só marcar a chamada como atendida 
quando realmente for atendida por uma fila

        //$agi->exec('ResetCDR','v');

        //Toca o audio de callback

        $agi->stream_file('nomedoarquivodeaudio');

        //Desliga a ligação

        $agi->hangup();

        return 0;

} catch (Exception $e) {

        $agi->exec("NOOP", '"'.$e->getMessage().'"');

        $agi->exec("GOTO", '"interno,'.$exten.',1"');

        return 0;

}

closelog();


Att,
Hélvio Junior
dCAA - Digium Certified Asterisk Administrator
SafeId - Gestão de identidades e Acessos
+55 41 | 9855-9300, single-sign-on.com.br
[email protected]

Em 14/09/2016 12:01, Vanessa Sather escreveu:
Bom dia.
Sei que é pedir demais porem estou na urgência e pergunto se alguem tem um script simples para dialplan mesmo contemplando callback? Gostaria de dar um toque no meu número fixo através do celular e o mesmo reconhecer meu cel e retornar a chamada.
Muito obrigada.
Vanessa.


_______________________________________________
KHOMP: completa linha de placas externas FXO, FXS, GSM e E1
Media Gateways de 1 a 64 E1s para SIP com R2, ISDN e SS7
Intercomunicador e acesso remoto via rede IP e telefones IP
Conheça todo o portfólio em www.Khomp.com
_______________________________________________
Para remover seu email desta lista, basta enviar um email em branco para 
[email protected]

_______________________________________________
KHOMP: completa linha de placas externas FXO, FXS, GSM e E1
Media Gateways de 1 a 64 E1s para SIP com R2, ISDN e SS7
Intercomunicador e acesso remoto via rede IP e telefones IP
Conheça todo o portfólio em www.Khomp.com
_______________________________________________
Para remover seu email desta lista, basta enviar um email em branco para 
[email protected]

Responder a