use of Read cmd with AGI

Home » Asterisk Users » use of Read cmd with AGI
Asterisk Users 4 Comments

Hello,

Using AGI script to accept the input from caller but input value is not getting stored in variable.

Extract from AGI Script:

$agi = new AGI();
$agi-> exec(‘Background’,’press_one0&press_two0&press_zero0′);
$agi-> exec(‘Read’,’NUMBER,,1,3′);
$agi-> verbose (“You have entered”.$NUMBER);

Console Output:
AGI Script Executing Application: (Background) Options: (press_one0&press_two0&press_zero0)

4 thoughts on - use of Read cmd with AGI

  • You need to use AGI to read the Asterisk variable.. Asterisk variables don’t magically become PHP ones.. Or you get Asterisk to process it instead using ${NUMBER}.

    S

  • Hi, try some like this:

    in SOME_AGI.agi:

    $agi = new AGI();
    $agi->answer();

    $_result = $agi->get_data(‘beep’, 3000, 20);
    $keys = $_result[‘result’];
    $agi->set_variable(“TECLA”, $keys);

    In the Dialplan:

    exten => s,1,Agi(SOME_AGI.agi)
    exten => s,n,NoOp(You have entered: ${TECLA})
    ….

    That way you export the variable “TECLA” to Asterisk dialplan….

    Regards!

    Atentamente,

  • Hello, I tried it but it doesn’t work. beep file gets played, and when I enter any digit(s), it doesn’t get stored in $keys variable.
    Regards,Kamlesh From: alejandro.beltran@setcolombia.com

    Hi, try some like this:
    in SOME_AGI.agi:
    $agi = new AGI();$agi->answer();
    $_result = $agi->get_data(‘beep’, 3000, 20);$keys = $_result[‘result’];$agi->set_variable(“TECLA”, $keys);…
    In the Dialplan:
    exten => s,1,Agi(SOME_AGI.agi)exten => s,n,NoOp(You have entered: ${TECLA})….
    That way you export the variable “TECLA” to Asterisk dialplan….
    Regards!
    Atentamente,– Luis Alejandro Beltr├ín Casta├▒eda.Gerente General.SetColombia SAS.Bogota – Colombia.Tel/Fax: (571) 4756296Movil: (57) 300-2721370www.setcolombia.com

  • Un-top-posting…

    [PERL snippet using get_data AGI command]

    1) Does enabling AGI debugging on the Asterisk console shed any clues?

    2) Try reducing your AGI script to the bare minium.

    3) Post the full source of your AGI and the Asterisk console log with AGI
    debugging enabled.