如何讓Asterisk根據來電號碼與號碼匹配轉發來電轉接?這兩個數字都存儲在MySQL數據庫中。MySQL,Asterisk撥號方案和呼叫轉移
3
A
回答
1
我一直在尋找最終看上去像這樣的解決方案:
[default]
exten => _X.,1,Set(ARRAY(${EXTEN}_phone)=${DTC_ICF(phone_number,${EXTEN})})
exten => _X.,n(callphone),Dial(SIP/metaswitch/${${EXTEN}_phone},26)
exten => _X.,n(end),Hangup()
1
This article應該這樣做。這是關於3行代碼和一些簡單的查詢來添加和刪除轉發規則。
3
對不起,對於長代碼示例,但它的一半以上是調試代碼,以幫助您設置它。
我假設你的服務器已經PHP與PDO庫一個現代版(在/usr/bin/php
),並有一個名爲fwd_table
的列caller_id
和destination
數據庫表。
在/ var/lib/asterisk/agi-bin中獲取PHP AGI庫的副本。然後創建一個名字類似forward_by_callerid.agi
文件,其中包含:
#!/usr/bin/php
<?php
ini_set('display_errors','false'); //Supress errors getting sent to the Asterisk process
require('phpagi.php');
$agi = new AGI();
try {
$pdo = new PDO('mysql:host='.$db_hostname.';dbname='.$db_database.';charset=UTF-8', $db_user, $db_pass);
} catch (PDOException $e) {
$agi->conlog("FAIL: Error connecting to the database! " . $e->getMessage());
die();
}
$find_fwd_by_callerid = $pdo->prepare('SELECT destination FROM fwd_table WHERE caller_id=? ');
$caller_id = $agi->request['agi_callerid'];
if($callerid=="unknown" or $callerid=="private" or $callerid==""){
$agi->conlog("Call came in without caller id, I give up");
exit;
}else{
$agi->conlog("Call came in with caller id number $caller_id.");
}
if($find_fwd_by_callerid->execute(array($caller_id)) === false){
$agi->conlog("Database problem searching for forward destination (find_fwd_by_callerid), croaking");
exit;
}
$found_fwds = $find_fwd_by_callerid->fetchAll();
if(count($found_fwds) > 0){
$destination = $found_contacts[0]['destination'];
$agi->set_variable('FWD_TO', $destination);
$agi->conlog("Caller ID matched, setting FWD_TO variable to ''");
}
?>
然後從撥號計劃,你可以這樣調用:
AGI(forward_by_callerid.agi)
如果你的數據庫有一個比賽,它會設置變量與善良,FWD_TO
。如果您需要更多幫助,將其集成到撥號計劃中,請編輯您的問題。
相關問題
- 1. Asterisk:始發呼叫不設置撥號方案中的CALLERID
- 2. Asterisk的呼叫轉移channells
- 3. 如何撥號以從撥號方案內發起呼叫?
- 4. Asterisk防止撥號方案連續重複的撥號方案
- 5. Asterisk收聽轉移呼叫的事件
- 6. Twilio - 轉移呼叫和顯示撥號前撥打的電話號碼
- 7. Asterisk撥號方案:清理分機
- 8. 多個呼叫使用星號的撥號方案
- 9. 答錄機撥號時Asterisk撥號方案未運行
- 10. 從Asterisk傳入的轉移呼叫中獲取電話號碼
- 11. Freeswitch - 使用撥號方案通過mod_curl呼叫
- 12. 如何自動將呼入呼叫轉移到Asterisk的外線號碼?
- 13. Asterisk呼叫終止
- 14. 使用Asterisk中的撥號方案獲取來電號碼
- 15. Asterisk - 搶先撥號
- 16. 星號中的自動呼叫分配或呼叫轉移
- 17. iPhone呼叫轉移
- 18. 呼叫轉移pjsua2
- 19. Twilio呼叫轉移
- 20. Twilio - 呼叫轉移
- 21. 帶星號的呼叫轉移GOIP16
- 22. Android的呼叫轉移號碼
- 23. Asterisk撥號方案中Exec()中的多個命令
- 24. 如何通過AMI在Asterisk中運行撥號方案?
- 25. 自動化Java中的Asterisk IVR(入站/出站撥號方案)
- 26. 在Android的撥號環來電呼叫
- 27. 任何撥號前的FreePBX呼叫宏
- 28. 星號撥號方案和擴展
- 29. 預測撥號:Asterisk-Jitsi
- 30. Asterisk PRI撥號器問題
非常接近。不包括MySQL問題的一部分,但我認爲它讓我走得很遠。只需要一些例子。謝謝! – afarnham 2008-09-16 14:48:07