Понимаю , что тема старая , пытаюсь сделать то же самое на основе FreePBX 2.11 . Создал Custom Destination - dynamic_did,_X.,1 - , перед этим в extensions_custom.conf создал контекст такого вида
[dynamic_did]
exten => _X.,1,Set(CHANNEL(language)=he)
exten => _X.,n,Set(CALLID=${CALLERID(num):-11})
exten => _X.,n,MYSQL(Connect connidcdr localhost <user> <pass> asteriskcdrdb utf8)
;; All CALL
;;exten => _X.,n,MYSQL(Query resultidcdr ${connidcdr} SELECT * FROM cdr WHERE dst LIKE '%${CALLID}%' ORDER BY calldate DESC)
;; NOANSWER CALL ONLY
exten => _X.,n,MYSQL(Query resultidcdr ${connidcdr} SELECT * FROM cdr WHERE dst LIKE '%${CALLID}%' AND disposition LIKE 'NO ANSWER' AND calldate >= DATE_SUB( NOW(), INTERVAL 24 HOUR)ORDER BY calldate DESC)
exten => _X.,n,MYSQL(Fetch fetchid ${resultidcdr} accid calldate clid src dst)
exten => _X.,n,Set(number=${src})
exten => _X.,n,NoOp(caller --> ${clid} callee --> ${dst})
exten => _X.,n,GOTOIF($["${dst}" = ""]?nodst:dst)
exten => _X.,n(dst),MYSQL(Clear ${resultidcdr})
exten => _X.,n,MYSQL(Disconnect ${connidcdr})
exten => _X.,n,Playback(/var/lib/asterisk/sounds/custom/agent)
exten => _X.,n,Wait(1)
exten => _X.,n,Dial(SIP/${number},20,tT)
exten => _X.,n,GotoIf($["${DIALSTATUS}" = "BUSY"]?nodst)
exten => _X.,n,GotoIf($["${DIALSTATUS}" = "NOANSWER"]?nodst)
exten => _X.,n,GotoIf($["${DIALSTATUS}" = "FAILED"]?nodst)
exten => _X.,n(nodst),MYSQL(Clear ${resultidcdr})
exten => _X.,n,MYSQL(Disconnect ${connidcdr})
exten => _X.,n,Goto(from-trunk,${DID},1)
exten => h,1,hangup()
Номер 072ХХХХХХХ ( в реале номер естественно полный , с номерами вместо Х ) направил на этот Custom Destination . Если перезванивать на этот номер с телефона на который звонили , то все срабатывает , внутренний номер звонит , но ..
1) Если внутренний номер не отвечает , т.е. должно сработать exten => _X.,n,Goto(from-trunk,${DID},1) , на деле получается
-- Nobody picked up in 20000 ms
== Extension Changed 788[ext-local] new state Idle for Notify User 340
== Extension Changed 788[ext-local] new state Idle for Notify User 750
-- Executing [_X.@dynamic_did:14] GotoIf("SIP/pop4_voipe-00008a97", "0?nodst") in new stack
-- Executing [_X.@dynamic_did:15] GotoIf("SIP/pop4_voipe-00008a97", "1?nodst") in new stack
-- Goto (dynamic_did,_X.,17)
-- Executing [_X.@dynamic_did:17] MYSQL("SIP/Trank-00008a97", "Clear 3") in new stack
[2017-01-05 10:56:01] WARNING[5343][C-00004562]: app_mysql.c:194 find_identifier: Identifier 3, identifier_type 2 not found in identifier list
[2017-01-05 10:56:01] WARNING[5343][C-00004562]: app_mysql.c:520 aMYSQL_clear: Invalid result identifier 3 passed in aMYSQL_clear
-- Executing [_X.@dynamic_did:18] MYSQL("SIP/Trunk-00008a97", "Disconnect 2") in new stack
[2017-01-05 10:56:01] WARNING[5343][C-00004562]: app_mysql.c:194 find_identifier: Identifier 2, identifier_type 1 not found in identifier list
[2017-01-05 10:56:01] WARNING[5343][C-00004562]: app_mysql.c:537 aMYSQL_disconnect: Invalid connection identifier 2 passed in aMYSQL_disconnect
-- Executing [_X.@dynamic_did:19] Goto("SIP/Trunk-00008a97", "from-trunk,,1") in new stack
-- Goto (from-trunk,_X.,1)
-- Executing [_X.@from-trunk:1] Set("SIP/Trunk-00008a97", "__FROM_DID=_X.") in new stack
-- Executing [_X.@from-trunk:2] NoOp("SIP/Trunk-00008a97", "Received an unknown call with DID set to _X.") in new stack
-- Executing [_X.@from-trunk:3] Goto("SIP/Trunk-00008a97", "s,a2") in new stack
-- Goto (from-trunk,s,2)
-- Executing [s@from-trunk:2] Answer("SIP/Trunk-00008a97", "") in new stack
-- Executing [s@from-trunk:3] Wait("SIP/Trunk-00008a97", "2") in new stack
-- Goto (macro-hangupcall,s,3)
-- Executing [s@from-trunk:4] Playback("SIP/Trunk-00008a97", "ss-noservice") in new stack
-- <SIP/Trunk-00008a97> Playing 'ss-noservice.gsm' (language 'he')
== Spawn extension (from-trunk, s, 4) exited non-zero on 'SIP/pop4_voipe-00008a97'
-- Executing [h@from-trunk:1] Macro("SIP/Trunk-00008a97", "hangupcall,") in new stack
-- Executing [s@macro-hangupcall:1] GotoIf("SIP/Trunk-00008a97", "1?theend") in new stack
-- Goto (macro-hangupcall,s,3)
-- Executing [s@macro-hangupcall:3] ExecIf("SIP/Trunk-00008a97", "0?Set(CDR(recordingfile)=)") in new stack
-- Executing [s@macro-hangupcall:4] Hangup("SIP/Trunk-00008a97", "") in new stack
и звонок обрывается , не понятно почему должно быть Goto(from-trunk,${DID},1 а на деле Goto("SIP/Trunk-00008a97", "from-trunk,,1 и FROM_DID=_X. если DID указан явно как входящий .
И 2) То же самое происходит если звонит на этот DID номер на который не звонил внутренний , т.е. звонок просто обрывается с сообщением , что номер на который позвонили не верен
-- Executing [0722155555@from-trunk-sip-trunk:2] Goto("SIP/Trunk-00008aa9", "from-trunk,072XXXXXXX,1") in new stack
-- Goto (from-trunk,072XXXXXXX,1)
-- Executing [072XXXXXXX@from-trunk:1] Set("SIP/Trunk-00008aa9", "__FROM_DID=072XXXXXXX") in new stack
-- Executing [072XXXXXXX@from-trunk:2] Gosub("SIP/Trunk-00008aa9", "app-blacklist-check,s,1()") in new stack
-- Executing [s@app-blacklist-check:1] GotoIf("SIP/Trunk-00008aa9", "0?blacklisted") in new stack
-- Executing [s@app-blacklist-check:2] Set("SIP/Trunk-00008aa9", "CALLED_BLACKLIST=1") in new stack
-- Executing [s@app-blacklist-check:3] Return("SIP/Trunk-00008aa9", "") in new stack
-- Executing [072XXXXXXX@from-trunk:3] Set("SIP/Trunk-00008aa9", "CHANNEL(language)=he") in new stack
-- Executing [072XXXXXXX@from-trunk:4] Set("SIP/Trunk-00008aa9", "CDR(did)=072XXXXXXX") in new stack
-- Executing [072XXXXXXX@from-trunk:5] ExecIf("SIP/Trunk-00008aa9", "0 ?Set(CALLERID(name)=077YYYYYYY)") in new stack
-- Executing [072XXXXXXX@from-trunk:6] Set("SIP/Trunk-00008aa9", "CHANNEL(musicclass)=default") in new stack
-- Executing [072XXXXXXX@from-trunk:7] Set("SIP/Trunk-00008aa9", "__MOHCLASS=default") in new stack
-- Executing [072XXXXXXX@from-trunk:8] Set("SIP/Trunk-00008aa9", "__CALLINGPRES_SV=allowed_not_screened") in new stack
-- Executing [072XXXXXXX@from-trunk:9] Set("SIP/Trunk-00008aa9", "CALLERPRES()=allowed_not_screened") in new stack
-- Executing [072XXXXXXX@from-trunk:10] Set("SIP/Trunk-00008aa9", "__ALERT_INFO=<http://127.0.0.1>;info=Outside") in new stack
-- Executing [072XXXXXXX@from-trunk:11] Goto("SIP/Trunk-00008aa9", "dynamic_did,_X.,1") in new stack
-- Goto (dynamic_did,_X.,1)
-- Executing [_X.@dynamic_did:1] Set("SIP/Trunk-00008aa9", "CHANNEL(language)=he") in new stack
-- Executing [_X.@dynamic_did:2] Set("SIP/Trunk-00008aa9", "CALLID=077YYYYYYY") in new stack
-- Executing [_X.@dynamic_did:3] MYSQL("SIP/Trunk-00008aa9", "Connect connidcdr localhost <user> <pass> asteriskcdrdb utf8") in new stack
-- Executing [_X.@dynamic_did:4] MYSQL("SIP/Trunk-00008aa9", "Query resultidcdr 2 SELECT * FROM cdr WHERE dst LIKE '%077YYYYYYY%' AND disposition LIKE 'NO ANSWER' AND calldate >= DATE_SUB( NOW(), INTERVAL 24 HOUR)ORDER BY calldate DESC") in new stack
-- Executing [_X.@dynamic_did:5] MYSQL("SIP/Trunk-00008aa9", "Fetch fetchid 3 accid calldate clid src dst") in new stack
-- Executing [_X.@dynamic_did:6] Set("SIP/Trunk-00008aa9", "number=") in new stack
-- Executing [_X.@dynamic_did:7] NoOp("SIP/Trunk-00008aa9", "caller --> callee --> ") in new stack
-- Executing [_X.@dynamic_did:8] GotoIf("SIP/Trunk-00008aa9", "1?nodst:dst") in new stack
-- Goto (dynamic_did,_X.,17)
-- Executing [_X.@dynamic_did:17] MYSQL("SIP/pop4_voipe-00008aa9", "Clear 3") in new stack
-- Executing [_X.@dynamic_did:18] MYSQL("SIP/pop4_voipe-00008aa9", "Disconnect 2") in new stack
-- Executing [_X.@dynamic_did:19] Goto("SIP/pop4_voipe-00008aa9", "from-trunk,,1") in new stack
-- Goto (from-trunk,_X.,1)
-- Executing [_X.@from-trunk:1] Set("SIP/Trunk-00008aa9", "__FROM_DID=_X.") in new stack
-- Executing [_X.@from-trunk:2] NoOp("SIP/Trunk-00008aa9", "Received an unknown call with DID set to _X.") in new stack
-- Executing [_X.@from-trunk:3] Goto("SIP/Trunk-00008aa9", "s,a2") in new stack
-- Goto (from-trunk,s,2)
-- Executing [s@from-trunk:2] Answer("SIP/Trunk-00008aa9", "") in new stack
-- Executing [s@from-trunk:3] Wait("SIP/Trunk-00008aa9", "2") in new stack
-- Executing [s@from-trunk:4] Playback("SIP/Trunk-00008aa9", "ss-noservice") in new stack
-- <SIP/Trunk-00008aa9> Playing 'ss-noservice.gsm' (language 'he')
== Spawn extension (from-trunk, s, 4) exited non-zero on 'SIP/Trunk-00008aa9'
-- Executing [h@from-trunk:1] Macro("SIP/Trunk-00008aa9", "hangupcall,") in new stack
-- Executing [s@macro-hangupcall:1] GotoIf("SIP/Trunk-00008aa9", "1?theend") in new stack
-- Goto (macro-hangupcall,s,3)
-- Executing [s@macro-hangupcall:3] ExecIf("SIP/Trunk-00008aa9", "0?Set(CDR(recordingfile)=)") in new stack
-- Executing [s@macro-hangupcall:4] Hangup("SIP/Trunk-00008aa9", "") in new stack
== Spawn extension (macro-hangupcall, s, 4) exited non-zero on 'SIP/Trunk-00008aa9' in macro 'hangupcall'
== Spawn extension (from-trunk, h, 1) exited non-zero on 'SIP/Trunk-00008aa9'
Зарание спасибо за помощь .