方法一:使用 voicemail.conf
需要修改以下檔案:
- /etc/asterisk/voicemail.conf
- /var/www/html/common/lib/common.defines.php
- /var/www/html/A2Billing_UI/Public/form_data/FG_var_card.inc
- /var/lib/asterisk/agi-bin/lib/Class.A2Billing.php
voicemail.conf:
[general]
...
...
sendvoicemail=yes ; Allow the user to compose and send a voicemail while inside
; VoiceMailMain() [option 5 from mailbox's advanced menu].
; If set to 'no', option 5 will not be listed.
searchcontexts=yes ; Current default behavior is to search only the default context
; if one is not specified. The older behavior was to search all contexts.
...
[default]
...
...
[a2b]
7008374947 => 7008374947,A Lang,your@email.com
common.defines.php:
...
// VOICEMAIL
define ("ACT_VOICEMAIL", true);
...
FG_var_card.inc:
註:A2B-1.9.4 已經內建有這些程式碼
reference to undefined name 'syntax' Exception of type 'MindTouch.Deki.Script.Runtime.DekiScriptUndefinedNameException' was thrown. (click for details)Callstack:
at User:alang/Private_Zone/A2Billing_專區/Voicemail_設置
MindTouch.Deki.Script.Runtime.DekiScriptUndefinedNameException: reference to undefined name 'syntax' Exception of type 'MindTouch.Deki.Script.Runtime.DekiScriptUndefinedNameException' was thrown.
at MindTouch.Deki.Script.Compiler.DekiScriptExpressionEvaluation.Visit (MindTouch.Deki.Script.Expr.DekiScriptVar expr, DekiScriptExpressionEvaluationState state) [0x00000] in <filename unknown>:0
at MindTouch.Deki.Script.Expr.DekiScriptVar.VisitWith[DekiScriptExpressionEvaluationState,Range] (IDekiScriptExpressionVisitor`2 visitor, DekiScriptExpressionEvaluationState state) [0x00000] in <filename unknown>:0
at MindTouch.Deki.Script.Compiler.DekiScriptExpressionEvaluation.Evaluate (MindTouch.Deki.Script.Expr.DekiScriptAccess expr, DekiScriptExpressionEvaluationState state, Boolean evaluateProperties) [0x00000] in <filename unknown>:0
at MindTouch.Deki.Script.Compiler.DekiScriptExpressionEvaluation.Visit (MindTouch.Deki.Script.Expr.DekiScriptAccess expr, DekiScriptExpressionEvaluationState state) [0x00000] in <filename unknown>:0
at MindTouch.Deki.Script.Expr.DekiScriptAccess.VisitWith[DekiScriptExpressionEvaluationState,Range] (IDekiScriptExpressionVisitor`2 visitor, DekiScriptExpressionEvaluationState state) [0x00000] in <filename unknown>:0
at MindTouch.Deki.Script.Compiler.DekiScriptExpressionEvaluation.Visit (MindTouch.Deki.Script.Expr.DekiScriptCall expr, DekiScriptExpressionEvaluationState state) [0x00000] in <filename unknown>:0
at MindTouch.Deki.Script.Expr.DekiScriptCall.VisitWith[DekiScriptExpressionEvaluationState,Range] (IDekiScriptExpressionVisitor`2 visitor, DekiScriptExpressionEvaluationState state) [0x00000] in <filename unknown>:0
at MindTouch.Deki.Script.Compiler.DekiScriptExpressionEvaluation.Visit (MindTouch.Deki.Script.Expr.DekiScriptSequence expr, DekiScriptExpressionEvaluationState state) [0x00000] in <filename unknown>:0
at MindTouch.Deki.Script.Expr.DekiScriptSequence.VisitWith[DekiScriptExpressionEvaluationState,Range] (IDekiScriptExpressionVisitor`2 visitor, DekiScriptExpressionEvaluationState state) [0x00000] in <filename unknown>:0
at MindTouch.Deki.Script.Compiler.DekiScriptExpressionEvaluation.Visit (MindTouch.Deki.Script.Expr.DekiScriptReturnScope expr, DekiScriptExpressionEvaluationState state) [0x00000] in <filename unknown>:0
TIPs:
修改了 common.defines.php & FG_var_card.inc 以後,在管理介面 > Customer 會多二個項目,PERMITTED VOICEMAIL, ACTIVE VOICEMAIL SERVICE,必須設定為 YES。
Class.A2Billing.php:
...
...
// Enable voicemail for this card. For DID and SIP/IAX call
var $voicemail = 1;
TIP:
預設此行是被註解的。
...
function call_did ($agi, &$RateEngine, $listdestination)
{
$res=0;
...
...
// IF VOIP CALL
if ($inst_listdestination[5]==1) {
...
...
// ELSEIF NOT VOIP CALL
} else {
...
// PERFORM THE CALL
$result_callperf = $RateEngine->rate_engine_performcall ($agi, $this -> destination, $this);
// alang: add this line
$dialstatus = $RateEngine->dialstatus;
if (!$result_callperf) {
$prompt="prepaid-callfollowme";
$agi-> stream_file($prompt, '#');
continue;
}
// alang: comment out this line
//$dialstatus = $RateEngine->dialstatus;
if (($RateEngine->dialstatus == "NOANSWER") || ($RateEngine->dialstatus == "BUSY") ||
($RateEngine->dialstatus == "CHANUNAVAIL") || ($RateEngine->dialstatus == "CONGESTION")) continue;
...
...
...
if ($this->voicemail) {
if (($dialstatus =="CHANUNAVAIL") || ($dialstatus == "CONGESTION") || ($dialstatus == "NOANSWER") || ($dialstatus =="BUSY")) {
// The following section will send the caller to VoiceMail with the unavailable priority.\
$dest_username = $this->username;
$this -> debug( INFO, $agi, __FILE__, __LINE__, "[STATUS] CHANNEL ($dialstatus) - GOTO VOICEMAIL ($dest_username)");
// alang: modify this line, a2b is the context of voicemail.conf
$vm_parameters = $this -> format_parameters ($dest_username.'@a2b,s');
$agi-> exec(VoiceMail, $vm_parameters);
}
}
...
...
TIPs:
- 如果是 DID 轉接後的語音留言,必須修改 function call_did;如果是 sip friend 則要修改 function call_sip_iax_buddy。
- 啟動 voicemail 的指令格式是 exec(Voicemail, XXXXXX@a2b,s)
XXXXXX 帳戶號碼,a2b 必須對應 voicemail.conf 的 context 名稱,功能參數 ,s 可換成 ,u,如果是 asterisk 1.4 必須改成 |s。