Dialplan — Trunk маршрутизация
Файл: /etc/asterisk/extensions_trunk.conf
[from-trunk-mcore]
exten => _+X.,1,Goto(from-trunk-mcore,${EXTEN:1},1)
exten => 000,1,NoOp(=== Hotline call from trunk ${CHANNEL(endpoint)} ===)
same => n,Set(HOTLINE_QUEUE=${ODBC_GET_HOTLINE_QUEUE()})
same => n,GotoIf($["${HOTLINE_QUEUE}" = ""]?hotline_not_configured,1)
same => n,NoOp(Routing trunk to hotline queue: ${HOTLINE_QUEUE})
same => n,Set(TENANT_ID=${ODBC_GET_QUEUE_TENANT(${HOTLINE_QUEUE})})
same => n,NoOp(Trunk hotline tenant_id: ${TENANT_ID})
same => n,Set(GREETING=${ODBC_GET_ROUTE_GREETING(${HOTLINE_QUEUE})})
same => n,NoOp(Trunk hotline greeting: ${GREETING})
same => n,Answer()
same => n,GotoIf($["${GREETING}" = ""]?hotline_trunk_skip,1)
same => n,Playback(${GREETING})
same => n(to_queue),Gosub(cdr-init,s,1(${HOTLINE_QUEUE},${TENANT_ID},000))
same => n,Set(__CDR_QUEUE_START_EPOCH=${EPOCH})
same => n,Queue(${HOTLINE_QUEUE},tT,,,300,,,cdr-agent-answer)
same => n,Hangup()
exten => hotline_trunk_skip,1,NoOp(No greeting for trunk hotline)
same => n,Goto(000,to_queue)
exten => hotline_not_configured,1,NoOp(Hotline not configured for trunk)
same => n,Answer()
same => n,Playback(callbox/system/callbox-invalid-input)
same => n,Hangup()
exten => hotline_trunk_skip,1,NoOp(No greeting for trunk hotline)
same => n,Goto(000,to_queue)
exten => hotline_not_configured,1,NoOp(Hotline not configured for trunk)
same => n,Answer()
same => n,Playback(callbox/system/callbox-invalid-input)
same => n,Hangup()
same => n,Hangup()
exten => _X.,1,NoOp(=== Incoming call from trunk: ${EXTEN} ===)
same => n,Set(CHANNEL(language)=ru)
same => n,Set(ORIGINAL_EXTEN=${EXTEN})
same => n,Set(ROUTE_DATA=${ODBC_GET_TENANT_BY_DID(${EXTEN})})
same => n,NoOp(Route data: ${ROUTE_DATA})
same => n,Set(TENANT_ID=${CUT(ROUTE_DATA,|,1)})
same => n,Set(DEST_TYPE=${CUT(ROUTE_DATA,|,2)})
same => n,Set(DEST_VALUE=${CUT(ROUTE_DATA,|,3)})
same => n,Set(GREETING_FILE=${CUT(ROUTE_DATA,|,4)})
same => n,Set(PERSONAL_DATA=${CUT(ROUTE_DATA,|,5)})
same => n,Set(RECORDING_NOTICE=${CUT(ROUTE_DATA,|,6)})
same => n,NoOp(Tenant: ${TENANT_ID}, Type: ${DEST_TYPE}, Destination: ${DEST_VALUE})
same => n,NoOp(Greeting: ${GREETING_FILE}, PersonalData: ${PERSONAL_DATA}, RecordingNotice: ${RECORDING_NOTICE})
same => n,GotoIf($["${TENANT_ID}" = ""]?unknown_did)
same => n,GotoIf($["${DEST_TYPE}" = "queue"]?route_to_queue)
same => n,GotoIf($["${DEST_TYPE}" = "extension"]?route_to_extension)
same => n,Goto(unknown_did)
same => n(route_to_queue),Answer()
same => n,Gosub(cdr-init,s,1(${DEST_VALUE},${TENANT_ID},${ORIGINAL_EXTEN}))
same => n,GotoIf($["${GREETING_FILE}" = ""]?check_hours)
same => n,Playback(${GREETING_FILE})
same => n(check_hours),Set(EPOCH_VAL=${EPOCH})
same => n,Set(DOW=${STRFTIME(${EPOCH_VAL},,%w)})
same => n,NoOp(Day of week: ${DOW})
same => n,Set(WORKING_STATUS=${ODBC_CHECK_WORKING_HOURS(${DEST_VALUE},${DOW},${TENANT_ID})})
same => n,NoOp(Working hours status: ${WORKING_STATUS})
same => n,GotoIf($["${WORKING_STATUS}" = "closed"]?closed)
same => n(check_operators),NoOp(Checking operators)
same => n,Set(TOTAL_MEMBERS=${QUEUE_MEMBER_COUNT(${DEST_VALUE})})
same => n,Set(PAUSED=${ODBC_COUNT_PAUSED_MEMBERS(${DEST_VALUE},${TENANT_ID})})
same => n,Set(AVAILABLE=${QUEUE_MEMBER(${DEST_VALUE},ready)})
same => n,NoOp(Total: ${TOTAL_MEMBERS}, Paused: ${PAUSED}, Available: ${AVAILABLE})
same => n,GotoIf($["${TOTAL_MEMBERS}" = "0"]?no_operators)
same => n,GotoIf($["${TOTAL_MEMBERS}" = "${PAUSED}"]?no_operators)
same => n,GotoIf($["${AVAILABLE}" = "0"]?all_busy)
same => n,Playback(callbox/templates/recording_notice_kz)
same => n,Playback(callbox/templates/recording_notice_ru)
same => n,GotoIf($["${PERSONAL_DATA}" != "1"]?enter_queue)
same => n,Playback(callbox/templates/personal_data_kz)
same => n,Playback(callbox/templates/personal_data_ru)
same => n(enter_queue),Set(__CDR_QUEUE_START_EPOCH=${EPOCH})
same => n,Queue(${DEST_VALUE},tT,,,300,,,cdr-agent-answer)
same => n,GotoIf($["${QUEUESTATUS}" = "LEAVEEMPTY"]?queue_left_empty)
same => n,GotoIf($["${QUEUESTATUS}" = "LEAVEUNAVAIL"]?queue_left_empty)
same => n,Hangup()
same => n(all_busy),NoOp(All operators busy)
same => n,Playback(callbox/templates/recording_notice_kz)
same => n,Playback(callbox/templates/recording_notice_ru)
same => n,GotoIf($["${PERSONAL_DATA}" != "1"]?play_wait_busy)
same => n,Playback(callbox/templates/personal_data_kz)
same => n,Playback(callbox/templates/personal_data_ru)
same => n(play_wait_busy),Playback(callbox/templates/wait_operator_kz)
same => n,Playback(callbox/templates/wait_operator_ru)
same => n(enter_queue_busy),Set(__CDR_QUEUE_START_EPOCH=${EPOCH})
same => n,Queue(${DEST_VALUE},tT,,,300,,,cdr-agent-answer)
same => n,GotoIf($["${QUEUESTATUS}" = "LEAVEEMPTY"]?queue_left_empty)
same => n,GotoIf($["${QUEUESTATUS}" = "LEAVEUNAVAIL"]?queue_left_empty)
same => n,Hangup()
same => n(no_operators),NoOp(No operators available)
same => n,Playback(callbox/templates/no_operators_kz)
same => n,Playback(callbox/templates/no_operators_ru)
same => n,Gosub(cdr-log-abandoned,s,1(queue_empty))
same => n,Hangup()
same => n(queue_left_empty),NoOp(Queue left empty: ${QUEUESTATUS})
same => n,Playback(callbox/templates/no_operators_kz)
same => n,Playback(callbox/templates/no_operators_ru)
same => n,Gosub(cdr-log-abandoned,s,1(queue_empty))
same => n,Hangup()
same => n(closed),NoOp(Outside working hours)
same => n,Playback(callbox/templates/non_working_hours_kz)
same => n,Playback(callbox/templates/non_working_hours_ru)
same => n,Gosub(cdr-log-abandoned,s,1(after_hours))
same => n,Hangup()
same => n(route_to_extension),NoOp(=== Extension routing to ${DEST_VALUE} ===)
same => n,Gosub(cdr-init-direct,s,1(${DEST_VALUE},${TENANT_ID},${ORIGINAL_EXTEN}))
same => n,Set(DEVICE_STATE=${DEVICE_STATE(PJSIP/${DEST_VALUE})})
same => n,NoOp(Device state: ${DEVICE_STATE})
same => n,GotoIf($["${DEVICE_STATE}" = "UNAVAILABLE"]?ext_unavailable)
same => n,GotoIf($["${DEVICE_STATE}" = "UNKNOWN"]?ext_unavailable)
same => n,GotoIf($["${GREETING_FILE}" = ""]?ext_check_recording)
same => n,Answer()
same => n,Playback(${GREETING_FILE})
same => n(ext_check_recording),GotoIf($["${RECORDING_NOTICE}" != "1"]?ext_check_personal_data)
same => n,GotoIf($["${DIALSTATUS}" = "ANSWER"]?ext_play_recording)
same => n,Answer()
same => n(ext_play_recording),Playback(callbox/templates/recording_notice_kz)
same => n,Playback(callbox/templates/recording_notice_ru)
same => n(ext_check_personal_data),GotoIf($["${PERSONAL_DATA}" != "1"]?dial_extension)
same => n,GotoIf($["${DIALSTATUS}" = "ANSWER"]?ext_play_personal)
same => n,Answer()
same => n(ext_play_personal),Playback(callbox/templates/personal_data_kz)
same => n,Playback(callbox/templates/personal_data_ru)
same => n(dial_extension),Set(ORG_PREFIX=${DEST_VALUE:0:3})
same => n,Goto(${ORG_PREFIX}-context,${DEST_VALUE},1)
same => n(ext_unavailable),NoOp(Terminal ${DEST_VALUE} unavailable - checking forwarding)
same => n,Set(ORG_PREFIX=${DEST_VALUE:0:3})
same => n,GotoIf(${DIALPLAN_EXISTS(${ORG_PREFIX}-context,${DEST_VALUE},1)}?${ORG_PREFIX}-context,${DEST_VALUE},1)
same => n,Answer()
same => n,Playback(callbox/templates/no_operators_kz)
same => n,Playback(callbox/templates/no_operators_ru)
same => n,Hangup()
same => n(unknown_did),NoOp(Unknown DID: ${EXTEN})
same => n,Answer()
same => n,Playback(silence/1)
same => n,Playback(invalid)
same => n,Hangup()
exten => h,1,Gosub(cdr-log-answered,s,1)
same => n,Gosub(cdr-log-direct,s,1)