Was this page helpful?

Call file 開發範例

    Call file 的開發技巧可應用在 Call-Back(電話回撥)、Predictive Dialer(預時撥號系統)、語音廣播等等系統。

    以最典型的應用-電話回撥的用途可以應用在很多方面,例如網頁客服、自動重撥、自動提醒等等,實現方式可以透過 AGI 或 Macro 方式來呼叫,以下介紹使用不同程式語言來撰寫的範例。

    SHELL(bash)

    shell 是所有 Linux 發行版都會內建的腳本語言,無須另外安裝,使用方便。

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

     

     Macro for Asterisk

    Asterisk 的巨集範例,以下巨集內容可以寫在 /etc/asterisk/extensions.conf 設定檔內。

    [macro-createfile]
    ;  {ARG1} Number to Dial    0312341234
    ;  {ARG2} Device/Trunk    SIP/VSP_Name
    ;  {ARG3} Context        from-internal
    ;  {ARG4} CallerID        "Name" <number>
    exten => s,1,Set(NumToCall=${ARG1})
    exten => s,n,System(echo Channel: ${ARG2}/${NumToCall} > /tmp/${NumToCall})
    exten => s,n,System(echo CallerID: ${ARG4} >> /tmp/${NumToCall})
    exten => s,n,System(echo MaxRetries: 0 >> /tmp/${NumToCall})
    exten => s,n,System(echo RetryTime: 120 >> /tmp/${NumToCall})
    exten => s,n,System(echo WaitTime: 20 >> /tmp/${NumToCall})
    exten => s,n,System(echo Context: ${ARG3} >> /tmp/${NumToCall})
    exten => s,n,System(echo Extension: ${NumToCall} >> /tmp/${NumToCall})
    exten => s,n,System(echo Priority: 1 >> /tmp/${NumToCall})
    exten => s,n,System(echo sleep 15 > /tmp/${NumToCall}.2)
    exten => s,n,System(echo mv /tmp/${NumToCall} /var/spool/asterisk/outgoing >> /tmp/${NumToCall}.2)
    exten => s,n,System(chmod 775 /tmp/${NumToCall}.2)
    exten => s,n,System(/tmp/${NumToCall}.2 &)
    exten => s,n,Hangup
    

    在自定的context或Dialplan都可以呼叫此巨集,簡單的範例可以這樣寫:

    ; Accepted Call Back Numbers
    exten => DID/CID,1,Macro(createfile,CID,SIP/GoTalk,callback,CID-Display)
    exten => DID/CID,n,HangUp
    
    Morning Call 應用

    這是飯店常見的電話提醒服務。

    [hotel-intern]
    exten => _*77*XXXXXXXXXXXX,1,Answer()
    exten => _*77*XXXXXXXXXXXX,n,Set(year=${EXTEN:4:4})
    exten => _*77*XXXXXXXXXXXX,n,Set(month=${EXTEN:8:2})
    exten => _*77*XXXXXXXXXXXX,n,Set(day=${EXTEN:10:2})
    exten => _*77*XXXXXXXXXXXX,n,Set(hours=${EXTEN:12:2})
    exten => _*77*XXXXXXXXXXXX,n,Set(minutes=${EXTEN:14:2})
    exten => _*77*XXXXXXXXXXXX,n,NoOp(Wake-up call scheduled for ${CALLERID(num)} at ${hours}:${minutes} on ${day}.${month}.${year}.)
    exten => _*77*XXXXXXXXXXXX,n,System(echo -e "Channel: SIP/${CALLERID(num)}\\nContext: wake-up\\nExtension: 23" > /tmp/${UNIQUEID}.call)
    exten => _*77*XXXXXXXXXXXX,n,System(touch -t ${year}${month}${day}${hours}${minutes} /tmp/${UNIQUEID}.call)
    exten => _*77*XXXXXXXXXXXX,n,System(mv /tmp/${UNIQUEID}.call /var/spool/asterisk/outgoing/)
    exten => _*77*XXXXXXXXXXXX,n,Playback(rqsted-wakeup-for)
    exten => _*77*XXXXXXXXXXXX,n,SayNumber(${hours})
    exten => _*77*XXXXXXXXXXXX,n,SayNumber(${minutes})
    exten => _*77*XXXXXXXXXXXX,n,Hangup()
    
    [wake-up]
    exten => 23,1,Answer()
    exten => 23,n,Wait(1)
    exten => 23,n,Playback(this-is-yr-wakeup-call)
    exten => 23,n,Wait(1)
    exten => 23,n,Hangup()
    

     

    Was this page helpful?
    標籤 (Edit tags)
    • No tags
    您必須 登入 才能發佈評論。
    Powered by MindTouch Core