-
Notifications
You must be signed in to change notification settings - Fork 0
/
extensions.conf
132 lines (115 loc) · 6.92 KB
/
extensions.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
[globals]
HOME_PHONE=${ENV(home_phone)}
UBUNTU_ZOIPER_SIP=${ENV(ubuntu_zoiper_sip)}
UBUNTU2_ZOIPER_SIP=${ENV(ubuntu2_zoiper_sip)}
MAC_ZOIPER_SIP=${ENV(mac_zoiper_sip)}
SOME_OTHER_SIP=${ENV(some_other_sip)}
RPI_SIP=${ENV(rpi_sip)}
[LocalSets]
; need to do something about outgoing calls
include=>UserServices
exten => _N.,1,Verbose(1,Caller has dialed an extension that does NOT begin with pound or 1)
same => n,Set(INCOMING_CALLERID=${SQL_ESC(${CALLERID(num)})}
same => n,Goto(main_menu,s,1)
exten => _#X,1,Verbose(1,Selected manage numberlist, i.e. whitelist and blacklist. Caller dialed ${EXTEN})
same => n,GotoIf($["${CALLERID(num)}"="${HOME_PHONE}""]?continue-to-manage-numberlist:subVoicemail,start,1) ; should only access this part from the home phone
same => n(continue-to-manage-numberlist),Set(OPTION=${SQL_ESC(${EXTEN:1})}); get the option number: was it #1 or #2?.
same => n,Verbose(OPTION=${OPTION})
same => n,Goto(manage_numberlist,start,1)
same => n(hangup),Hangup()
exten => *98,1,NoOp(Access voicemail retrieval.)
same => n,Verbose(1, Entering voicemail retreival extension)
same => n,Set(JITTERBUFFER(fixed)=default)
same => n,VoiceMailMain(101@default)
exten => 101,1,Dial(SIP/${UBUNTU_ZOIPER_SIP})
exten => 102,1,Dial(SIP/${UBUNTU2_ZOIPER_SIP})
exten => 103,1,Dial(SIP/${RPI_SIP})
exten => 104,1,Dial(SIP/${MAC_ZOIPER_SIP})
exten => 105,1,Dial(SIP/${MAC_ZOIPER_SIP})
[main_menu]
exten => s,1,NoOp()
; this should cause robo-callers to hang up
; same => n,Zapateller()
; set a variable to hold the callerid. Will pass this through if and when connecting the call to the 'home phone'
; more info on CALLERID variables is here: http://www.voip-info.org/wiki/view/Asterisk+func+callerid
same => n,Verbose(2, INCOMING_CALLERID)
same => n,Verbose(1, num = ${CALLERID(num)})
same => n,Verbose(1, name = ${CALLERID(name)})
same => n,Verbose(1, all = ${CALLERID(all)})
same => n,Verbose(1, dnid = ${CALLERID(dnid)})
same => n,Verbose(1, rdnis = ${CALLERID(rdnis)})
same => n,Verbose(1, pres = ${CALLERID(pres)})
same => n,Verbose(1, ton = ${CALLERID(ton)})
; page 645 of the Asterisk book
same => n,Verbose(1, (${CALLERID(name)}), sql escaped callerid_name is ${SQL_ESC(mac)} )
same => n,Set(CDR(callerid_num) =${SQL_ESC(${CALLERID(num)})})
same => n,Set(CDR(callerid_name)=${SQL_ESC(${CALLERID(name)})})
same => n,Set(CDR(callerid_all) =${SQL_ESC(${CALLERID(all)})})
same => n,Set(CDR(callerid_dnid)=${SQL_ESC(${CALLERID(dnid)})})
; if there is no callerid, send the call to the Local Channel for playing the greeting and asking for the extension
same => n,GoSubIf($[${ISNULL(${INCOMING_CALLERID})}]?subVoicemail,start,1)
; if the callerid is on the whitelist, send the call right through. If it is on the blacklist, send directly to voicemail
;same => n,GoSubIf($["${INCOMING_CALLERID}"="mac_zoiper_sip_3"]?passthrough)
same => n,Set(LIST_TYPE=${GENERIC_SQL(SELECT list_type FROM numberlist WHERE callerid_num='${INCOMING_CALLERID}' )})
same => n,Verbose(1,LIST_TYPE=${LIST_TYPE})
same => n,GotoIf($[${ODBCROWS} < 1]?ask-for-extension) ; the number is not in the numberlist
same => n,GotoIf($[${LIST_TYPE}=1]?bingo,1) ; 1 is whitelist
same => n,GotoIf($[${LIST_TYPE}=2]?subVoicemail,start,1) ; 2 is blacklist
; If there is a caller ID number, and this number is neither on the blacklist nor on the whitelist, then ask for the extension number
same => n(ask-for-extension),Verbose(1, Caller ${CALLERID(all)} has entered the auto attendant)
same => n,Answer()
same => n,Set(TIMEOUT(digit)=2)
same => n,Wait(1)
same => n,Background(daygreeting)
same => n,WaitExten(4)
same => n,Goto(subVoicemail,start,1)
exten => _.,1,Verbose(1, Caller entered extension ${EXTEN})
same => n,Set(PASSTHROUGH=${GENERIC_SQL(SELECT IF(COUNT(1)>0, 1, 0) FROM extensions_passthrough WHERE extension='${SQL_ESC(${EXTEN})}')})
same => n,Verbose(1,PASSTHROUGH=${PASSTHROUGH}, SQL=SELECT IF(COUNT(1)>0, 1, 0) FROM extensions_passthrough WHERE extension='${SQL_ESC(${EXTEN})}')
same => n,GotoIf($[${PASSTHROUGH}]?bingo,1:subVoicemail,start,1)
exten => bingo,1,Verbose(1, Caller gets through)
same => n(bingo),Dial(SIP/rpi_sip)
[manage_numberlist]
; need to secure this somehow... maybe by callerid_num of the calling phone?
exten => start,1,Verbose(1,Entering the manage numberlist context. Caller selected option ${OPTION})
same => n,GotoIf($["${INCOMING_CALLERID}"!="${CALLERID(num)}"]?subVoicemail,start,1) ; double check - want only authorized user to proceed
same => n,Verbose(1,The caller selected ${OPTION}. The caller is calling from '${SQL_ESC(${CALLERID(num)})}')
; The next line gets the most recent record in the cdr table that is not from this call.
; same => n,Set(LAST_CALLERID_NUM=${GENERIC_SQL(SELECT callerid_num FROM cdr ORDER BY start DESC LIMIT 1)})
same => n,Set(LAST_CALLERID_NUM=${GENERIC_SQL(SELECT src FROM cdr WHERE src != '${SQL_ESC(${CALLERID(num)})}' ORDER BY start DESC LIMIT 1)})
same => n,Verbose(1,The last number that called in was ${LAST_CALLERID_NUM})
same => n,GotoIf($[${ODBCROWS} < 0]?hangup) ; if there was no such last number then go to the hangup step
same => n,GotoIf($[${OPTION}=1|${OPTION}=2]?update-or-insert-into-db:hangup)
same => n,GotoIf($[${OPTION}=3]?remove-from-db:hangup)
same => n(hangup),Hangup() ; really should give a message that there was no last call found
same => n(update-or-insert-into-db),Verbose(1,updating or inserting into db.......) ; I'm not going to bother with upsert, will instead check
same => n,Set(NUMBER_IN_NUMBERLIST=${GENERIC_SQL(SELECT callerid_num FROM numberlist WHERE callerid_num='${LAST_CALLERID_NUM}')})
same => n,Verbose(1, NUMBER_IN_NUMBERLIST=${NUMBER_IN_NUMBERLIST}, ODBCROWS=${ODBCROWS})
same => n,GotoIf($[${ODBCROWS} < 1]?insert-into-db:update-db) ; if no results returned, then insert; otherwise, update
same => n(update-db),Verbose(1,Updating db.......)
same => n,Set(GENERIC_SQL()=UPDATE numberlist SET list_type='${OPTION}' WHERE callerid_num='${LAST_CALLERID_NUM}' )
same => n,Hangup()
same => n(insert-into-db),Verbose(1,Inserting into db.......)
same => n,Set(GENERIC_SQL()=INSERT INTO numberlist (callerid_num, list_type) VALUES ('${LAST_CALLERID_NUM}','${OPTION}'))
same => n,Hangup()
same => n(remove-from-db),Verbose(Removing ${LAST_CALLERID_NUM} from numberlist table in database)
same => n,Set(GENERIC_SQL()=DELETE FROM numberlist WHERE callerid_num='${LAST_CALLERID_NUM}')
same => n,Hangup()
[subVoicemail]
exten => start,1,Verbose(1, Entering voicemail context)
same => n,Voicemail(101@default,u)
same => n,Hangup()
; need to password secure this
exten => *98,1,NoOp(Access voicemail retrieval.)
same => n,Set(JITTERBUFFER(fixed)=default)
same => n,VoiceMailMain()
; need to password secure this
[UserServices]
exten => 500,1,Playback(vm-intro)
same => n,Record(daygreeting.wav)
same => n,Playback(daygreeting)
same => n,Hangup;
exten => 501,1,Playback(vm-intro)
same => n,Record(mainmenu.wav)
same => n,Playback(mainmenu.wav)
same => n,Hangup