DP: CallBack 應用實例

    客戶需求說明

    •  新增一個 CallBack.php,並且可以使其他應用程式透過 URL 觸發撥號,例如 http://xxx.xxx.xxx/callback.php?to_number=1234567 。
    • CallBack.php 以 AMI 方式與 Asterisk 連接並建立外撥通話。
    • 當 1234567 用戶接起電話後,會聽到一段語音,如果用戶按 1,電話會轉接到一個指定的號碼,例如是 666666
    • 不管任何情形,通話結束後,系統必須觸發一段 URL,例如 http://yyy.yyy.yyy/finished.php?to_number=1234567。

    主要檔案

    manager.conf:

    [callback]
    secret=qsxesz8825252
    deny=0.0.0.0/0.0.0.0
    permit=127.0.0.1/255.255.255.0
    read=originate
    write=originate
    

    CallBack.php:

    reference to undefined name 'syntax' Exception of type 'MindTouch.Deki.Script.Runtime.DekiScriptUndefinedNameException' was thrown. (click for details)

    Dialplan:

    [internal]
    include => demo
    include => outgoing
    
    [outgoing]
    exten => _XXXXX.,1,Noop(Dialing out thru Skype)
    exten => _XXXXX.,n,Set(DIAL_TIMEOUT=40)
    exten => _XXXXX.,n,Dial(SIP/skype/${EXTEN},${DIAL_TIMEOUT})
    exten => _XXXXX.,n,Congestion(5)
    
    exten => h,1,Hangup
    exten => i,1,Hangup
    exten => t,1,Hangup
    
    [php_callback]
    exten => _cbX.,1,Noop(This call is made from CallBack)
    exten => _cbX.,n,Set(Call_From=${CALLERID(num)})
    exten => _cbX.,n,Answer
    exten => _cbX.,n(restart),Set(TIMEOUT(digit)=5)      ; Set Digit Timeout to 5 seconds
    exten => _cbX.,n,Set(TIMEOUT(response)=10)  ; Set Response Timeout to 10 seconds
    exten => _cbX.,n,Set(AGENT=${EXTEN:2})
    exten => _cbX.,n,BackGround(custom/cjc_no_funds_call)
    exten => _cbX.,n,WaitExten()
    
    exten => 1,1,Noop(Caller pressed 1 so the call will bridge with the number ${AGENT})
    exten => 1,n,Set(DIAL_TIMEOUT=40)
    exten => 1,n,Dial(SIP/skype/${AGENT},${DIAL_TIMEOUT})
    exten => 1,n,Hangup
    
    exten => i,1,Noop(Caller pressed invalid number)
    exten => i,n,Goto(cb${AGENT},restart)
    
    exten => t,1,Noop(Caller don't make any decisions)
    exten => t,n,Goto(cb${AGENT},restart)
    
    exten => h,1,Noop(The Call has been terminated.)
    exten => h,n,Noop(Hitting the link http://finishedcall.cheapjailcalls.com/finished.php?to_number=${Call_From})
    exten => h,n,Set(foo=${CURL(http://finishedcall.cheapjailcalls.com/finished.php?to_number=${Call_From})})
    exten => h,n,Noop(The HTTP Response Codes: ${foo})
    exten => h,n,Hangup
    

    Q&A

    Q: 使用 .call file 的通話,CDR 的通話時間不正確?

    Ans: 兩個解法

    1. [建議]修改 Channel: Local/XXXX@from-internal,在末端加上 /n
    2. 修改 Channel: Local/XXXX@from-internal,將 Local 改成 SIP
    3. 參閱:http://comments.gmane.org/gmane.comp...sk.user/270662
    標籤 (Edit tags)
    • No tags
    您必須 登入 才能發佈評論。
    Powered by MindTouch Core