Hi.
Try to use MySQL integration. Please can someone look through my dial plan to point out any obvious errors in it?
Server has 2 incoming trunks. One trunk with fixed incoming number as 8(BBB)KKKKKKK. Other tunk with many (more than 500) incoming numbers as +7(GGG)KKKKKKK. I want to check: working hours, holidays then I want to record speech + pass information about call to CRM. I have two extensions 1001 and 1002 + one mobile for backup…
I need to change dialplan on the fly. In production.
context
exten
priority
app
appdata
incoming
s
1
NoOp
Start incoming call from ${CALLERID(all)}
incoming
s
2
Set
CALLERID(name)=${CALLERID(num)}
incoming
s
3
GotoIfTime
18:00-10:00,*,27,Apr?mayholidays,s,1
incoming
s
4
GotoIfTime
, ,1
incoming
s
5
GotoIfTime
18:00-09:00,*,8,May?mayholidays,s,1
incoming
s
6
GotoIfTime
20:00-09:00,mon-fri,, ?offwork,s,1
incoming
s
7
GotoIfTime
18:00-10:00,sat-sun,, ?offwork,s,1
incoming
s
8
GoTo
work,s,1
mayholidays
s
1
Answer
mayholidays
s
2
Playback
holiday_eve
offwork
s
1
Answer
offwork
s
2
Playback
offwork_eve
work
s
1
Set
CALLFILENAME=${UNIQUEID}${STRFTIME(${EPOCH},%d%m%Y %H-%M)}${CALLERID(num)} ${EXTEN}.wav
work
s
2
MixMonitor
/var/spool/asterisk/monitor/${CALLFILENAME}
work
s
3
Set
CDR(userfield)=${CALLFILENAME}
work
s
4
Set
RESP=${ODBC_ZD_REGISTER_CALL(${CDR(uniqueid)},${CDR(linkedid)},${CDR(src)},${CDR(dst)},${CDR(dcontext)},${CDR(lastapp)},${CDR(disposition)},${CDR(sequence)},${CALLFILENAME})}
work
s
5
Dial
PJSIP/1001,5,tT
work
s
6
Dial
PJSIP/1002,10,tT
work
s
7
Dial
PJSIP/BACKUPNUMBER@FIXEDTRUNK,20,tT
work
h
1
Set
RESP=${ODBC_ZD_UPDATE_CALL(${CDR(disposition)},${CDR(uniqueid)},${CDR(linkedid)},${CDR(billsec)})}
from-internal
_1XXX
1
Dial
PJSIP/${EXTEN}
from-internal
_8XXXXXXXXXX
1
Dial
PJSIP/${EXTEN}@FIXEDTRUNK
My idea is transfer incoming calls from both trunks to single procedure…
Livitin:
GotoIfTime , ,1
Missing ?
In any case, should use simple GoTo, with no time field.
You failed to provide the logs.
It is a miscopy.. I don’t know why it copied in such format… It should be a
*,*,1|5|9|10,May?mayholidays,s,1
In general… Is it correct to use such a design for previously unknown incoming numbers?
It was an incorrect markup
*,*,1|5|9|10,May?mayholidays,s,1
Vertical bar is a markup for table columns and asterisk for italics.
You need to protect most of the table contents with back ticks.
You haven’t used this information in your dialplan, and, l without logs, I can’t tell if you need to.
Livitin:
BACKUPNUMBER
I created test enviroment and made working settings:
context
exten
priority
app
appdata
from-pstn
_X.
1
NoOp
from-pstn
_X.
2
Set
CALLERID(name)=${CALLERID(num)}
from-pstn
_X.
3
GotoIfTime
18:00-10:00,*,27,Apr?from-pstn,${EXTEN},17
from-pstn
_X.
4
GotoIfTime
, ,1
from-pstn
_X.
5
GotoIfTime
18:00-09:00,*,8,May?from-pstn,${EXTEN},17
from-pstn
_X.
6
NoOp
from-pstn
_X.
7
NoOp
from-pstn
_X.
8
GotoIfTime
20:00-09:00,mon-fri,, ?from-pstn,${EXTEN},20
from-pstn
_X.
9
GotoIfTime
18:00-10:00,sat-sun,, ?from-pstn,${EXTEN},20
from-pstn
_X.
10
Set
CALLFILENAME=${UNIQUEID}${STRFTIME(${EPOCH},%d%m%Y %H-%M)}${CALLERID(num)} ${EXTEN}.wav
from-pstn
_X.
11
MixMonitor
/var/spool/asterisk/monitor/${CALLFILENAME},ab
from-pstn
_X.
12
Set
CDR(userfield)=${CALLFILENAME}
from-pstn
_X.
13
Set
RESP=${ODBC_ZD_REGISTER_CALL(${CDR(uniqueid)},${CDR(linkedid)},${CDR(src)},${CDR(dst)},${CDR(dcontext)},${CDR(lastapp)},${CDR(disposition)},${CDR(sequence)},${CALLFILENAME})}
from-pstn
_X.
14
Dial
PJSIP/1001,10,tT
from-pstn
_X.
15
Dial
PJSIP/1002,15,tT
from-pstn
_X.
16
Dial
PJSIP/BACKUPNUMBER@FIXEDTRUNK,20,tT
from-pstn
_X.
17
Answer
from-pstn
_X.
18
Playback
holiday_eve
from-pstn
_X.
19
Hangup
from-pstn
_X.
20
Answer
from-pstn
_X.
21
Playback
offwork_eve
from-pstn
_X.
22
Hangup
from-pstn
h
1
NoOp
from-pstn
h
2
Set
RESP=${ODBC_ZD_UPDATE_CALL(${CDR(disposition)},${CDR(uniqueid)},${CDR(linkedid)},${CDR(billsec)})}
from-internal
_1XXX
1
Dial
PJSIP/${EXTEN}
from-internal
_X.
1
Dial
PJSIP/${EXTEN}@FIXEDTRUNK
from-pstn
s
1
Goto
from-pstn,FIXEDTRUNKNUMBER,1
Now I see right inserts and updates of CRM-database for both incoming channels.
system
Closed
August 30, 2025, 2:15pm
7
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.