由於 Asterisk 的版本不盡相同,所產生的 AMI 訊息內容也有所不同,此篇說明如何修改合適 AsteriskClient.php,使 VtigerCRM 可正確顯示 pop-up。
系統環境
- Ubuntu 11
- Asterisk 1.8.7.1
- VtigerCRM 5.3
A. 在 VtigerCRM 紀錄來電的 AMI 訊息內容:
cd /var/www/vtigercrm/cron/modules/PBXManager
php php 520AsteriskClient_fix_by_alang.php | tee vtigercrm-popup.log
從外部撥一通電話到 Asterisk,且轉接到指定的分機,該分機號有設在 VtigerCRM 內,掛斷電話且結束這個程式後,vtigercrm-popup.log 將紀錄所有過程的 AMI 內容。
B. 分析 AMI 內容及 PHP 程式的對應:
1. 搜尋 Ring 在 vtigercrm-popup.log 發現如下內容:
Event: Newstate^M
Privilege: call,all^M
Channel: SIP/iptel-0000000c^M
ChannelState: 4^M
ChannelStateDesc: Ring^M
CallerIDNum: 800677522^M
CallerIDName: alang-nb^M
ConnectedLineNum: ^M
ConnectedLineName: ^M
Uniqueid: 1322552384.12^M
這訊息會與這段程式碼 AsteriskClient.php 相對應:
reference to undefined name 'syntax' Exception of type 'MindTouch.Deki.Script.Runtime.DekiScriptUndefinedNameException' was thrown. (click for details)Callstack:
at User:alang/Private_Zone/整合_VtigerCRM_與_Asterisk/修改合適的_AsteriskClient.php
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
分析重點:
- ChannelStateDesc 與 VtigerCRM 的 PBXManager 模組設定的 Asterisk 版本有關。Asterisk 1.8 者設定為 1.6。
- CallerIDNum 名稱及回傳值是否與實際相符。
- 確認 Table vtiger_asteriskincomingevents 是否有紀錄產生,並且各欄位都有值。