本文介绍了星号get_variable,在Perl AGI中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对Asterisk AGI并不陌生.我正在将perl与星号agi一起使用.

I am little new to Asterisk AGI. I am using perl with asterisk agi.

我需要使用Perl星号agi设计IVR解决方案.

I need to design an IVR solution using Perl asterisk agi.

我写了一些代码,它执行得很好.

I have write a little code and it is executing fine.

#!/usr/bin/perl -w
use strict;
use warnings;
  use Asterisk::AGI;
  my $agi = new Asterisk::AGI;
  my $option1 = "";
  my $option2 = "";

$agi->exec("Read","option1,recording-201503252343,1,,,");
$option2 = $agi->get_variable("$option1");
$agi->exec("NoOp","$option1");

if($option2 == 1)
{
  $agi->exec("Playback","hello-world");
  $agi->exec("Goto","English,s,1");
}


星号拨号计划:-

exten => 12345,1,Answer()
exten => 12345,2,AGI(agi_new-new.pl)
exten => 12345,n,NoOP(${AGISTATUS})
exten => 12345,n,Hangup()


实际上,我在代码中所做的是,我希望用户拨打IVR引导的分机号,其中提示2个选项,当他/她输入要存储的选项时,他必须在2个选项之间进行选择数字到一个变量,以便我在该变量上使用条件.我使用get_variable来获取变量,但是当我按所需的选项时,它会获得dtmf输入,但不会通过get_variable命令将其存储在变量中.


Actually what i did in the code is that i want a user to dial the extension lead by the IVR in which 2 options are prompted and he has to choose between 2 options when he/she enter the options i want to store that digit into a variable so that i use condition on that variable.I use get_variable to get the variable but when i press the desired option it gets that dtmf input but it is not storing in the variable via the command get_variable.

请为此,我不需要什么帮助.

please i need little help on this.

如果有人可以帮助,将不胜感激.

if anyone could help it will be highly appreciated.

推荐答案

$ AGI-> get_variable()获取存储在通道数据中的变量.捕获的DTMF数字不会存储在当前通道的数据中.对于您的情况,您需要使用 $ AGI-> get_data().. >

$AGI->get_variable() gets variable stored in channel data. Catched DTMF digits don't stored in the data of current channel. For your case you need use$AGI->get_data().

# Wait 3 seconds for press button
my $option1 = $agi->get_data('recording-201503252343',3000,1);
if ($option1 == 1) {
  # do something
}

在您的示例中,您有错误.已定义$option1为空.您执行命令Read并在option1中捕获了DTMF,接下来您要获取$option1的值(空).在Read命令的示例中是错字(option1而不是$option1),或者是错误的代码,可以正常工作.

And in your example you have errors. Defined $option1 is empty. You executing command Read with catching DTMF in option1 and next you want get value of $option1 (empty). Either it's a typo in the example in the Read command (option1 instead of $option1) or it is a wrong code, which works as expected.

这篇关于星号get_variable,在Perl AGI中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-21 05:29