-
Notifications
You must be signed in to change notification settings - Fork 3
/
extensions-pngnpbx-abc-v15.ael2
351 lines (340 loc) · 17.8 KB
/
extensions-pngnpbx-abc-v15.ael2
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
/*
* Always Be Conferencing
* ======================
*
* Creator: chris @ Penguin PBX Solutions
* Version: 15b
* Release: 2020-01-28
* License: Creative Commons Zero v1.0 Universal (CC0 1.0)
*
* ABC starts your Conference Bridge in ASTERISK(R) by Originating calls
* to other participants. They will be joined *before* they answer the call.
* There is no beep or prompt before they join. Conference will continue
* until all parties disconnect - so the original caller can hang up, even
* before the call is connected to any other participants, and those
* yet-to-answer participants can chat amongst themselves when they finally
* do answer the call. (There are no marked or admin users.)
*
* Call Detail Records will be saved in files based on whatever ABC type name
* you specify ie. the account code will be set to this name on all channels.
* In the examples (below) it would be "abctest.csv" in the same directory
* as your "Master.csv" (assuming you are using CSV for CDRs.)
*
* Optionally you can record the call (see example #2 below).
* Look for the recordings in "/var/spool/asterisk/monitor/" directory.
* The ABC type name will be used to prefix the files (one file per leg.)
* CAREFUL when recording eg. legal issues, drive space, privacy, etc.
*
* This file is configured in the ASTERISK Extension Language. You'll want to
* copy or include this file into the "/etc/asterisk/extensions.ael" file.
* But then you can call it from standard dial plan in "extensions.conf"
* -- or "extensions_custom.conf" if you are using FreePBX(R) -- via a context
* similar to the following:
*
* [from-internal-custom-1]
* exten = 933,1,NoOp(Always Be Conferencing - PenguinPBX.com) ; Please copy and change as you wish!
* same = n,Set(path=PJSIP/${EXTEN}@#YOUR-TRUNK#) ; CHANGE ME! Endpoint section defined in your PJSIP configuration.
* same = n,Set(callback=3035557729) ; CHANGE ME! Your call-back telephone number (probably 10 digits in the USA.)
* same = n,Set(friend=PJSIP/1113) ; CHANGE ME! The local PJSIP endpoint to bridge into the call.
* same = n,Set(abctypename=abctest) ; CHANGE ME! Use abctest as the conf type name.
* same = n,Set(ringtime=120) ; MAYBE CHANGE ME! Rings remote end / path for 2 minutes.
* same = n,AELSub(pngnpbx-abc-simple,${abctypename}) ; Simple setup. (Either "abc-simple" or "abc-init" must be first.)
* same = n,AELSub(pngnpbx-abc-path,1,${ringtime},${path}) ; Set the first (and only) call path to use on call to remote end.
* same = n,AELSub(pngnpbx-abc-remote,${callback}) ; Dial out the path/trunk using your call-back number as the Caller ID number.
* same = n,AELSub(pngnpbx-abc-friend,1,${friend}) ; Bridge in the other attendee automatically.
* same = n,AELSub(pngnpbx-abc-howdy-yall) ; Enter the conference. No more dial plan processing occurs for caller.
*
* ...be sure to include the context from wherever your phones start, or setup
* a Custom Destination / Custom Extension for it in your PBX GUI.
*
* Here is the same example, but in extensions.AEL configuration instead of standard extensions.CONF format:
*
* context from-internal-custom-1-ael {
* 933 => {
* NoOp(Always Be Conferencing - PenguinPBX.com); // Please copy and change as you wish!
* Set(path=PJSIP/${EXTEN}@#YOUR-TRUNK#); // CHANGE ME! Endpoint section defined in your PJSIP configuration.
* Set(callback=3035557729); // CHANGE ME! Your call-back telephone number (probably 10 digits in the USA.)
* Set(friend=PJSIP/1113); // CHANGE ME! The local PJSIP endpoint to bridge into the call.
* Set(abctypename=abctest); // CHANGE ME! Use abctest as the conf type name.
* Set(ringtime=120); // MAYBE CHANGE ME! Rings remote end / path for 2 minutes.
* &pngnpbx-abc-simple(${abctypename}); // Simple setup. (Either "abc-simple" or "abc-init" must be first.)
* &pngnpbx-abc-path(1,${ringtime},${path}); // Set the first (and only) call path to use on call to remote end.
* &pngnpbx-abc-remote(${callback}); // Dial out the path/trunk using your call-back number as the Caller ID number.
* &pngnpbx-abc-friend(1,${friend}); // Bridge in the other attendee automatically.
* &pngnpbx-abc-howdy-yall(); // Enter the conference. No more dial plan processing occurs for caller.
* }
* }
*
* Slightly more involved example -- adds multiple paths, call recording, GPS based on caller, and two additional friend phones:
*
* [from-internal-custom-2]
* exten = 222,1,NoOp(Always Be Conferencing - PenguinPBX.com) ; Please copy and change as you wish!
* same = n,Set(gpsurl=https://abc.penguinpbx.com/loc/) ; URL that will be included in Geolocation SIP header.
* same = n,Set(path1=DAHDI/#YOUR-TRUNK-1#/${EXTEN}) ; Endpoint section defined in your DAHDI configuration.
* same = n,Set(path2=PJSIP/${EXTEN}@#YOUR-TRUNK-2#) ; A PJSIP endpoint section - used if first path is down/unreachable.
* same = n,Set(path3=PJSIP/${EXTEN}@#YOUR-TRUNK-3#) ; Yet another endpoint section defined in your PJSIP configuration.
* same = n,AELSub(pngnpbx-abc-init,abctest,record,3600,) ; Use abctest as the conf type name, save WAV audios, and limit to 1 hour.
* same = n,AELSub(pngnpbx-abc-path,1,10,${path1}) ; Set the first call path / trunk name to use on call to remote end. Ring 10 seconds.
* same = n,AELSub(pngnpbx-abc-path,2,60,${path2}) ; Set the second call path - used only on failover of first call path. Ring 1 minute.
* same = n,AELSub(pngnpbx-abc-path,3,300,${path3}) ; Set the third call path - used only on failover of second call path. Ring 5 minutes.
* same = n,NoOp(About to change flow based on caller ID number.) ; Specifically changing between 1101 and 1102 in this example.
* exten = 222/1101,n,AELSub(pngnpbx-abc-gps,39.739,-104.990,${gpsurl}) ; Set Geolocation SIP header to URL and GPS co-ordinates #1 (optional.)
* exten = 222/1102,s,AELSub(pngnpbx-abc-gps,39.588,-105.644,${gpsurl}) ; Set Geolocation SIP header to URL and GPS co-ordinates #2 (optional.)
* exten = 222/1101,n,AELSub(pngnpbx-abc-remote,3035557729) ; Dial out the trunk(s).
* exten = 222/1102,s,AELSub(pngnpbx-abc-remote,3035557729) ; Dial out the trunk(s) using a different call-back number as the Caller ID number.
* exten = 222,n,NoOp(Remote dial started. Now adding friends to call.) ; Most critical is the remote call.
* same = n,AELSub(pngnpbx-abc-friend,1,PJSIP/1113) ; Bridge in friend.
* same = n,AELSub(pngnpbx-abc-friend,2,PJSIP/1114) ; Bridge in another friend.
* same = n,AELSub(pngnpbx-abc-friend,3,PJSIP/1115) ; Bridge in yet another friend. (Up to 20 total participants by default.)
* same = n,AELSub(pngnpbx-abc-howdy-yall) ; Enter the conference. No more dial plan processing occurs for caller.
*
* IMPORTANT:
* YOU MUST CHANGE #YOUR-TRUNK-s# and choose valid Call-Back numbers !!!
* ALSO CHANGE 1101, 1102, 1113, 1114, and 1115 to match your extension numbers.
* AND if you want to send GPS co-ordinates, then please change those, too!
*
* Tested with PJSIP on ASTERISK version 15 but should work on 13, 16 and 17.
* It should also work with any channel technology (see DAHDI in example #2.)
* Non-numeric extension numbers should work, but you should test it yourself.
* Actually you should probably test and verify with multiple test calls.
*
* Frequently Asked Questions
* ==========================
*
* Question:
* How do I change the volume ?
* Answer:
* Press * to increase the listening volume.
* Press 0 to decrease the listening volume.
* There are no other in-conference controls.
*
* Question:
* Why do I hear ring back tone until the friend(s) pick up and answer ?
* Answer:
* You'll need to add a new line to indications.conf for each tone zone
* you offer to your users in order to produce a 'silent' ringer.
*
* (...scroll down to find the section...)
* [us]
* description = United States / North America
* silent = 0/15000
* (...the rest of the tones...)
*
* ...but to avoid a restart, for testing, on the Asterisk CLI, you can do:
* CLI> indication add us silent 0/15000
*
*
* ASTERISK, FreePBX and DAHDI are registered trademarks of Sangoma.
* Penguin PBX Solutions is not affiliated with Sangoma.
*
*/
/* Either "simple" or "init" macro needs to be entered first,
* from somewhere outside of this file, in order to activate the
* conference room. */
macro pngnpbx-abc-simple(type_) {
&pngnpbx-abc-init(${type_},,,);
return;
}
/* The "init" macro (re)sets up several things for the conference room. */
macro pngnpbx-abc-init(type_,record_,conftimeout_,abcid_) {
Set(startstamp=${STRFTIME(,UTC,%F %H:%M:%S.%3q)} UTC);
DumpChan(5);
if( ${LEN(${type_})} > 0 ) {
Set(pngnpbx_abc_type=${type_});
} else {
Set(pngnpbx_abc_type=default);
}
Set(CHANNEL(accountcode)=${pngnpbx_abc_type});
if( ${LEN(${abcid_})} > 0 ) {
Set(pngnpbx_abc_id=${FILTER(a-zA-Z0-9,${abcid_})});
} else {
// This default only works if each phone has a unique caller ID number.
// Otherwise, you'll need to specify your own conference ID number.
Set(pngnpbx_abc_id=${FILTER(a-zA-Z0-9,${CALLERID(num)})});
}
Set(cnftmt=${FILTER(0-9,${conftimeout_})});
if( ${LEN(${cnftmt})} == 0 ) {
Set(cnftmt=14400);
}
// TODO: Check if the conference is already/still running.
DBdeltree(pngnpbx/abc/${pngnpbx_abc_id});
Set(DB(pngnpbx/abc/${pngnpbx_abc_id}/init)=${startstamp});
Set(DB(pngnpbx/abc/${pngnpbx_abc_id}/type)=${pngnpbx_abc_type});
Set(DB(pngnpbx/abc/${pngnpbx_abc_id}/cidnum)=${CALLERID(num)});
Set(DB(pngnpbx/abc/${pngnpbx_abc_id}/cidname)=${CALLERID(name)});
Set(DB(pngnpbx/abc/${pngnpbx_abc_id}/dnid)=${CALLERID(DNID)});
Set(DB(pngnpbx/abc/${pngnpbx_abc_id}/conftimeout)=${cnftmt});
if( "x${TOLOWER(${record_})}" == "xrecord" ) {
Set(DB(pngnpbx/abc/${pngnpbx_abc_id}/record)=yes);
} else {
Set(DB(pngnpbx/abc/${pngnpbx_abc_id}/record)=no);
}
return;
}
/* The "remote" macro should be entered once per conference.
* It is (arguably) the most important destination and probably what the user dialed. */
macro pngnpbx-abc-remote(cidnum_) {
Set(DB(pngnpbx/abc/${pngnpbx_abc_id}/outboundcidnum)=${cidnum_});
Originate(Local/${pngnpbx_abc_id}@pngnpbx-abc-bridge,exten,pngnpbx-abc-dial,${pngnpbx_abc_id}-0ABC,1,1);
return;
}
/* The "friend" macro can be entered multiple times, once per each additional participant. */
macro pngnpbx-abc-friend(position_,dialstr_) {
Set(DB(pngnpbx/abc/${pngnpbx_abc_id}/friend/${position_}/dialstr)=${dialstr_});
Originate(Local/${pngnpbx_abc_id}@pngnpbx-abc-bridge,exten,pngnpbx-abc-dial,${pngnpbx_abc_id}-${position_},1,1);
return;
}
/* The "paths" macro supports multiple dial strings to try and
* reach the far end, in a failover manner, in case some routes are down. */
macro pngnpbx-abc-path(position_,timeout_,dialstr_) {
Set(DB(pngnpbx/abc/${pngnpbx_abc_id}/outpath/${position_}/dialstr)=${dialstr_});
Set(DB(pngnpbx/abc/${pngnpbx_abc_id}/outpath/${position_}/timeout)=${timeout_});
return;
}
/* The "gps" macro is optional; if used it should be entered immediately after "init". */
macro pngnpbx-abc-gps(lat_,lon_,url_) {
if( ${LEN(${lat_})} > 0 ) {
Set(DB(pngnpbx/abc/${pngnpbx_abc_id}/gps/lat)=${lat_});
}
if( ${LEN(${lon_})} > 0 ) {
Set(DB(pngnpbx/abc/${pngnpbx_abc_id}/gps/lon)=${lon_});
}
if( ${LEN(${lurl_})} > 0 ) {
Set(DB(pngnpbx/abc/${pngnpbx_abc_id}/gps/url)=${url_});
}
return;
}
/* The "geohdrs" macro is another internal helper, only utilized in tandem with "gps" macro. */
macro pngnpbx-abc-geohdrs(abcid_) {
// TODO: check if this is an outgoing PJSIP channel
Set(lat=${DB(pngnpbx/abc/${abcid_}/gps/lat)});
Set(lon=${DB(pngnpbx/abc/${abcid_}/gps/lon)});
Set(url=${DB(pngnpbx/abc/${abcid_}/gps/url)});
Set(PJSIP_HEADER(add,Geolocation)=<${url}?lat=${lat}&lon=${lon}>);
Set(PJSIP_HEADER(add,Geolocation-Routing)=no);
return;
}
/* The "cbo" macro is internal and helps avoid editing confbridge.conf file. */
macro pngnpbx-abc-cbo(abcid_) {
Set(cnftmt=${DB(pngnpbx/abc/${abcid_}/conftimeout)});
Set(TIMEOUT(absolute)=${cnftmt});
Set(dorecord=${DB(pngnpbx/abc/${abcid_}/record)});
if( "x${dorecord}" = "xyes" ) {
Set(abctype=${DB(pngnpbx/abc/${abcid_}/type)});
Monitor(wav,${abctype}-${abcid_}-${UNIQUEID});
}
CONFBRIDGE(user,admin)=no;
CONFBRIDGE(user,announce_join_leave)=no;
CONFBRIDGE(user,announce_only_user)=no;
CONFBRIDGE(user,announce_user_count)=no;
CONFBRIDGE(user,dsp_drop_silence)=yes;
CONFBRIDGE(user,end_marked)=no;
CONFBRIDGE(user,jitterbuffer)=yes;
CONFBRIDGE(user,music_on_hold_when_empty)=no;
CONFBRIDGE(user,quiet)=yes;
CONFBRIDGE(user,startmuted)=no;
CONFBRIDGE(user,timeout)=${cnftmt};
CONFBRIDGE(user,wait_marked)=no;
CONFBRIDGE(bridge,max_members)=20;
// Dynamic menu change requires first choosing template.
// TODO: file a bug report because no template = crash
CONFBRIDGE(menu,template)=default_menu;
CONFBRIDGE(menu,*)=increase_listening_volume;
CONFBRIDGE(menu,0)=decrease_listening_volume;
CONFBRIDGE(menu,1)=no_op;
CONFBRIDGE(menu,2)=no_op;
CONFBRIDGE(menu,3)=no_op;
CONFBRIDGE(menu,4)=no_op;
CONFBRIDGE(menu,5)=no_op;
CONFBRIDGE(menu,6)=no_op;
CONFBRIDGE(menu,7)=no_op;
CONFBRIDGE(menu,8)=no_op;
CONFBRIDGE(menu,9)=no_op;
return;
}
/* The "howdy-yall" macro is the final needed step for connecting the caller. */
macro pngnpbx-abc-howdy-yall() {
CONNECTEDLINE(num,i) = ${CALLERID(DNID)};
CONNECTEDLINE(name,i) = "${TOUPPER(${pngnpbx_abc_type})} ConfCall";
CONNECTEDLINE(pres) = allowed;
&pngnpbx-abc-cbo(${pngnpbx_abc_id});
Set(nowstamp=${STRFTIME(,UTC,%F %H:%M:%S.%3q)} UTC);
Set(DB(pngnpbx/abc/${pngnpbx_abc_id}/howdy)=${nowstamp});
ConfBridge(pngnpbx-abc-${pngnpbx_abc_id});
return;
}
/* The "bridge" context puts spooled calls in the conference. */
context pngnpbx-abc-bridge {
_[a-zA-Z0-9]. => {
Answer();
Set(abcid=${FILTER(a-zA-Z0-9,${EXTEN})});
Set(abctype=${DB(pngnpbx/abc/${abcid}/type)});
Set(CHANNEL(accountcode)=${abctype});
&pngnpbx-abc-cbo(${abcid});
ConfBridge(pngnpbx-abc-${abcid});
}
}
/* The "dial" context actually makes the phones ring. */
context pngnpbx-abc-dial {
_[a-zA-Z0-9].-. => {
Set(abcid=${FILTER(a-zA-Z0-9,${CUT(EXTEN,-,1)})});
Set(position=${FILTER(0-9,${CUT(EXTEN,-,2)})});
Set(tofriend=${DB(pngnpbx/abc/${abcid}/friend/${position}/dialstr)});
Set(outboundcidnum=${DB(pngnpbx/abc/${abcid}/outboundcidnum)});
Set(abctype=${DB(pngnpbx/abc/${abcid}/type)});
Set(abccidnum=${DB(pngnpbx/abc/${abcid}/cidnum)});
Set(abccidname=${DB(pngnpbx/abc/${abcid}/cidname)});
Set(abcdnid=${DB(pngnpbx/abc/${abcid}/dnid)});
Set(cnftmt=${DB(pngnpbx/abc/${abcid}/conftimeout)});
Set(CHANNEL(accountcode)=${abctype});
Set(TIMEOUT(absolute)=cnftmt);
if( ${LEN(${tofriend})} > 0 ) {
Set(CALLERID(num)=${abccidnum});
Set(CALLERID(name)=${TOUPPER(${abctype})}:${abccidname} dialed ${abcdnid} as ${outboundcidnum});
// The silent ringer should be defined in indications.conf.
// See more info at the top of this file.
Set(dialopt=ir(silent));
// TODO: Add Alert-Info headers for auto-answer.
// Try to dial out a couple of times, one minute each try...
Dial(${tofriend},60,${dialopt});
if( "${DIALSTATUS}" != "ANSWERED" ) {
Wait(2);
Dial(${tofriend},60,${dialopt});
}
} else {
Set(dialopt=i);
Set(CALLERID(num)=${outboundcidnum});
Set(lat=${DB(pngnpbx/abc/${abcid}/gps/lat)});
Set(lon=${DB(pngnpbx/abc/${abcid}/gps/lon)});
if( ${LEN(${lat})} == 0 || ${LEN(${lon})} == 0 ) {
Set(CALLERID(name)=${abccidname});
} else {
// Really cool if/when the provider lets this get to the far end (some do!)
Set(CALLERID(name)=LAT${lat}LON${lon}:${abccidname});
Set(gpsurl=${DB(pngnpbx/abc/${abcid}/gps/url)});
// No biggee if no URL at least we modded/overloaded the caller ID name.
if( ${LEN(${gpsurl})} > 0 ) {
// Macros in AEL are Gosubs with snake-like extension names.
// (Maybe pronounced 'sssssss'.)
Set(dialopt=ib(pngnpbx-abc-geohdrs^~~s~~^1(${abcid})));
// TODO: Add Contact header for setting name and call back number (on some providers.)
}
}
for( i=1; ${i} <= 3; i=${i} + 1 ) {
Set(opdialstr=${DB(pngnpbx/abc/${abcid}/outpath/${i}/dialstr)});
Set(optimeout=${DB(pngnpbx/abc/${abcid}/outpath/${i}/timeout)});
if( ${LEN(${opdialstr})} == 0 ) {
break;
}
if( ${LEN(${optimeout})} == 0 ) {
Set(optimeout=300);
}
Dial(${opdialstr},${optimeout},${dialopt});
if( "${DIALSTATUS}" == "ANSWERED" ) {
break;
}
Wait(2);
}
}
}
}