| | 130 | ;------------------------------------------------------------------------ |
|---|
| | 131 | ; [macro-vm] |
|---|
| | 132 | ;------------------------------------------------------------------------ |
|---|
| | 133 | ; CONTEXT: macro-vm |
|---|
| | 134 | ; PURPOSE: call voicemail system and extend with personal ivr |
|---|
| | 135 | ; |
|---|
| | 136 | ; Under normal use, this macro will call the voicemail system with the extension and |
|---|
| | 137 | ; desired greeting mode of busy, unavailable or as specified with direct voicemail |
|---|
| | 138 | ; calls (usually unavailable) when entered from destinations. |
|---|
| | 139 | ; |
|---|
| | 140 | ; The voicemail system's two greetings have been 'hijacked' as follows to extend the |
|---|
| | 141 | ; system by giving the option of a private 'ivr' for each voicemail user. The following |
|---|
| | 142 | ; applies to both the busy and unavailable modes of voicemail and can be applied to one |
|---|
| | 143 | ; or both, and differently. |
|---|
| | 144 | ; |
|---|
| | 145 | ; Global Defaults: |
|---|
| | 146 | ; |
|---|
| | 147 | ; The following are default values, used in both busy and unavail modes if no specific |
|---|
| | 148 | ; values are specified. |
|---|
| | 149 | ; |
|---|
| | 150 | ; VMX_REPEAT |
|---|
| | 151 | ; The number of times to repeat the users message if no option is pressed. |
|---|
| | 152 | ; VMX_TIMEOUT |
|---|
| | 153 | ; The timeout to wait after playing message before repeating or giving up. |
|---|
| | 154 | ; VMX_LOOPS |
|---|
| | 155 | ; The number of times it should replay the message and check for an option when |
|---|
| | 156 | ; an invalid option is pressed. |
|---|
| | 157 | ; |
|---|
| | 158 | ; VMX_OPTS_DOVM |
|---|
| | 159 | ; Default voicemail option to use if vm is chosen as an option. No options will |
|---|
| | 160 | ; cause Allison's generic message, 's' will go straight to beep. |
|---|
| | 161 | ; VMX_OPTS_TIMEOUT |
|---|
| | 162 | ; Default voicemail option to use if it times out with no options. No options will |
|---|
| | 163 | ; cause Allison's generic message, 's' will go straight to beep. |
|---|
| | 164 | ; IF THE USER PRESSES # - it will look like a timeout as well since no option will |
|---|
| | 165 | ; be presented. If the user wishes to enable a mode where a caller can press # |
|---|
| | 166 | ; during their message and it goes straight to voicemail with only a 'beep' then |
|---|
| | 167 | ; this should be set to 's'. |
|---|
| | 168 | ; VMX_OPTS_LOOPS |
|---|
| | 169 | ; Default voicemail option to use if to many wrong options occur. No options will |
|---|
| | 170 | ; cause Allison's generic message, 's' will go straight to beep. |
|---|
| | 171 | ; |
|---|
| | 172 | ; VMX_CONTEXT |
|---|
| | 173 | ; Default context for user destinations if not supplied in the user's settings |
|---|
| | 174 | ; VMX_PRI |
|---|
| | 175 | ; Default priority for user destinations if not supplied in the user's settings |
|---|
| | 176 | ; |
|---|
| | 177 | ; VMX_TIMEDEST_CONTEXT |
|---|
| | 178 | ; Default context for timeout destination if not supplied in the user's settings |
|---|
| | 179 | ; VMX_TIMEDEST_EXT |
|---|
| | 180 | ; Default extension for timeout destination if not supplied in the user's settings |
|---|
| | 181 | ; VMX_TIMEDEST_PRI |
|---|
| | 182 | ; Default priority for timeout destination if not supplied in the user's settings |
|---|
| | 183 | ; |
|---|
| | 184 | ; VMX_LOOPDEST_CONTEXT |
|---|
| | 185 | ; Default context for loops destination if not supplied in the user's settings |
|---|
| | 186 | ; VMX_LOOPDEST_EXT |
|---|
| | 187 | ; Default extension for loops destination if not supplied in the user's settings |
|---|
| | 188 | ; VMX_LOOPDEST_PRI |
|---|
| | 189 | ; Default priority for loops destination if not supplied in the user's settings |
|---|
| | 190 | ; |
|---|
| | 191 | ; |
|---|
| | 192 | ; The AMPUSER database variable has been extended with a 'vmx' tree (vm-extension). A |
|---|
| | 193 | ; duplicate set is included for both unavail and busy. You could choose for to have an |
|---|
| | 194 | ; ivr when unavail is taken, but not with busy - or a different once with busy. |
|---|
| | 195 | ; The full list is below, each specific entry is futher described: |
|---|
| | 196 | ; |
|---|
| | 197 | ; state: Whether teh current mode is enabled or disabled. Anything but 'enabled' is |
|---|
| | 198 | ; treated as disabled. |
|---|
| | 199 | ; repeat: This is the number of times that the users message should be played after the |
|---|
| | 200 | ; timeout if the user has not entered anything. It is just a variable to the |
|---|
| | 201 | ; Read() function which will do the repeating. |
|---|
| | 202 | ; timeout: This is how long to wait after the message has been read for a response from |
|---|
| | 203 | ; the user. A caller can enter a digit any time during the playback. |
|---|
| | 204 | ; loops: This is the number of loops that the system will allow a caller to retry if |
|---|
| | 205 | ; they enter a bad menu choice, before going to the loop failover destination |
|---|
| | 206 | ; vmxopts: This is the vm options to send to the voicemail command used when a specific |
|---|
| | 207 | ; voicemail destination is chosen (inidcated by 'dovm' in the ext field). This is |
|---|
| | 208 | ; typically either set to 's' or left blank. When set to 's' there will be no |
|---|
| | 209 | ; message played when entering the voicemail, just a beep. When blank, you will |
|---|
| | 210 | ; have Allison's generic message played. It is not typical to play the greetings |
|---|
| | 211 | ; since they have been 'hijacked' for these IVR's and from a caller's perspecitive |
|---|
| | 212 | ; this system appears interconnected with the voicemail so instructions can be |
|---|
| | 213 | ; left there. |
|---|
| | 214 | ; timedest: The three variables: ext, context and pri are the goto destination if the caller |
|---|
| | 215 | ; enters no options and it timesout. None have to be set and a system default |
|---|
| | 216 | ; will be used. If just ext is set, then defaults will be used for context and |
|---|
| | 217 | ; pri, etc. |
|---|
| | 218 | ; loopdest: This is identical to timedest but used if the caller exceeds the maximum invalid |
|---|
| | 219 | ; menu choices. |
|---|
| | 220 | ; [0-9*]: The user can specify up to 11 ivr options, all as single digits from 0-9 or *. The |
|---|
| | 221 | ; # key can not be used since it is used as a terminator key for the Read command |
|---|
| | 222 | ; and will never be returned. A minimum of the ext must be specified for each valid |
|---|
| | 223 | ; option and as above, the context and priority can also be specified if the default |
|---|
| | 224 | ; is not to be used. |
|---|
| | 225 | ; Option '0' takes on a special meaning. Since a user is able to break out of the |
|---|
| | 226 | ; voicemail command once entering it with a 0, if specified, the 0 destination will |
|---|
| | 227 | ; be used. |
|---|
| | 228 | ; Option '*' can also be used to breakout. It is undecided at this point whether |
|---|
| | 229 | ; providing that option will be used as well. (probably should). |
|---|
| | 230 | ; |
|---|
| | 231 | ; |
|---|
| | 232 | ; /AMPUSER/<ext>/vmx/[busy|unavail]/state: enabled|disabled |
|---|
| | 233 | ; /AMPUSER/<ext>/vmx/[busy|unavail]/repeat: n (times to repeat message) |
|---|
| | 234 | ; /AMPUSER/<ext>/vmx/[busy|unavail]/timeout: n (timeout to wait for digit) |
|---|
| | 235 | ; /AMPUSER/<ext>/vmx/[busy|unavail]/loops: n (loop returies for invalid entries) |
|---|
| | 236 | ; /AMPUSER/<ext>/vmx/[busy|unavail]/vmxopts/dovm: vmoptions (if ext is dovm) |
|---|
| | 237 | ; /AMPUSER/<ext>/vmx/[busy|unavail]/vmxopts/timeout: vmoptions (if timeout) |
|---|
| | 238 | ; /AMPUSER/<ext>/vmx/[busy|unavail]/vmxopts/loops: vmoptions (if loops) |
|---|
| | 239 | ; /AMPUSER/<ext>/vmx/[busy|unavail]/timedest/ext: extension (if timeout) |
|---|
| | 240 | ; /AMPUSER/<ext>/vmx/[busy|unavail]/timedest/context: context (if timeout) |
|---|
| | 241 | ; /AMPUSER/<ext>/vmx/[busy|unavail]/timedest/pri: priority (if timeout) |
|---|
| | 242 | ; /AMPUSER/<ext>/vmx/[busy|unavail]/loopdest/ext: extension (if too many failures) |
|---|
| | 243 | ; /AMPUSER/<ext>/vmx/[busy|unavail]/loopdest/context: context (if too many failures) |
|---|
| | 244 | ; /AMPUSER/<ext>/vmx/[busy|unavail]/loopdest/pri: priority (if too many failures) |
|---|
| | 245 | ; /AMPUSER/<ext>/vmx/[busy|unavail]/[0-9*]/ext: extension (dovm for vm access) |
|---|
| | 246 | ; /AMPUSER/<ext>/vmx/[busy|unavail]/[0-9*]/context: context |
|---|
| | 247 | ; /AMPUSER/<ext>/vmx/[busy|unavail]/[0-9*]/pri: priority |
|---|
| | 248 | ;------------------------------------------------------------------------ |
|---|
| | 264 | |
|---|
| | 265 | |
|---|
| | 266 | ; If vmx not enabled for the current mode,then jump to normal voicemail behavior |
|---|
| | 267 | ; |
|---|
| | 268 | exten => vmx,1,Set(MODE=${IF($["${ARG2}"="BUSY"]?busy:unavail)}) |
|---|
| | 269 | exten => vmx,n,Noop(Checking if ext ${ARG1} is enabled: ${DB(AMPUSER/${ARG1}/vmx/${MODE}/state)}) |
|---|
| | 270 | exten => vmx,n,GotoIf($["${DB(AMPUSER/${ARG1}/vmx/${MODE}/state)}" != "enabled"]?s-${ARG2},1) |
|---|
| | 271 | |
|---|
| | 272 | ; If the required voicemail file does not exist, then abort and go to normal voicemail behavior |
|---|
| | 273 | ; TODO: figure out which is proper file (.wav or .WAV) and maybe find a better way |
|---|
| | 274 | ; |
|---|
| | 275 | exten => vmx,n,Macro(get-vmcontext,${ARG1}) |
|---|
| | 276 | exten => vmx,n(file),System(ls /var/spool/asterisk/voicemail/${VMCONTEXT}/${ARG1}/${MODE}.wav) |
|---|
| | 277 | |
|---|
| | 278 | ; Get the repeat, timeout and loop times to use if they are overriden form the global settings |
|---|
| | 279 | ; |
|---|
| | 280 | exten => vmx,n,Set(LOOPCOUNT=0) |
|---|
| | 281 | exten => vmx,n,GotoIf($["${DB_EXISTS(AMPUSER/${ARG1}/vmx/${MODE}/repeat)}" = "0"]?vmxtime) |
|---|
| | 282 | exten => vmx,n,Set(VMX_REPEAT=${DB_RESULT}) |
|---|
| | 283 | exten => vmx,n(vmxtime),GotoIf($["${DB_EXISTS(AMPUSER/${ARG1}/vmx/${MODE}/timeout)}" = "0"]?vmxloops) |
|---|
| | 284 | exten => vmx,n,Set(VMX_TIMEOUT=${DB_RESULT}) |
|---|
| | 285 | exten => vmx,n(vmxloops),GotoIf($["${DB_EXISTS(AMPUSER/${ARG1}/vmx/${MODE}/loops)}" = "0"]?vmxanswer) |
|---|
| | 286 | exten => vmx,n,Set(VMX_LOOPS=${DB_RESULT}) |
|---|
| | 287 | exten => vmx,n(vmxanswer),Answer() |
|---|
| | 288 | |
|---|
| | 289 | ; Now play the users voicemail recording as the basis for their ivr, the Read command will repeat as needed and if it timesout |
|---|
| | 290 | ; then we go to the timeout. Otherwise handle invalid options by looping until the limit until a valid option is played. |
|---|
| | 291 | ; |
|---|
| | 292 | exten => vmx,n(loopstart),Read(ACTION,/var/spool/asterisk/voicemail/${VMCONTEXT}/${ARG1}/${MODE},1,skip,${VMX_REPEAT},${VMX_TIMEOUT}) |
|---|
| | 293 | exten => vmx,n,GotoIf($["${EXISTS(${ACTION})}" = "1"]?checkopt) |
|---|
| | 294 | |
|---|
| | 295 | ; If we are here we timed out, go to the required destination |
|---|
| | 296 | ; |
|---|
| | 297 | exten => vmx,n(noopt),Noop(Timeout: going to timeout dest) |
|---|
| | 298 | exten => vmx,n,Set(VMX_OPTS=${VMX_OPTS_TIMEOUT}) |
|---|
| | 299 | exten => vmx,n,GotoIf($["${DB_EXISTS(AMPUSER/${ARG1}/vmx/${MODE}/vmxopts/timeout)}" = "0"]?chktime) |
|---|
| | 300 | exten => vmx,n,Set(VMX_OPTS=${DB_RESULT}) |
|---|
| | 301 | exten => vmx,n(chktime),GotoIf($["${DB_EXISTS(AMPUSER/${ARG1}/vmx/${MODE}/timedest/ext)}" = "0"]?dotime) |
|---|
| | 302 | exten => vmx,n,Set(VMX_TIMEDEST_EXT=${DB_RESULT}) |
|---|
| | 303 | exten => vmx,n,GotoIf($["${DB_EXISTS(AMPUSER/${ARG1}/vmx/${MODE}/timedest/context)}" = "0"]?timepri) |
|---|
| | 304 | exten => vmx,n,Set(VMX_TIMEDEST_CONTEXT=${DB_RESULT}) |
|---|
| | 305 | exten => vmx,n(timepri),GotoIf($["${DB_EXISTS(AMPUSER/${ARG1}/vmx/${MODE}/timedest/pri)}" = "0"]?dotime) |
|---|
| | 306 | exten => vmx,n,Set(VMX_TIMEDEST_PRI=${DB_RESULT}) |
|---|
| | 307 | exten => vmx,n(dotime),Goto(${VMX_TIMEDEST_CONTEXT},${VMX_TIMEDEST_EXT},${VMX_TIMEDEST_PRI}) |
|---|
| | 308 | |
|---|
| | 309 | ; We got an option, check if the option is defined, or one of the system defaults |
|---|
| | 310 | ; |
|---|
| | 311 | exten => vmx,n(checkopt),GotoIf($["${DB_EXISTS(AMPUSER/${ARG1}/vmx/${MODE}/${ACTION}/ext)}" = "1"]?doopt) |
|---|
| | 312 | exten => vmx,n,GotoIf($["${ACTION}" = "0"]?o,1) |
|---|
| | 313 | exten => vmx,n,GotoIf($["${ACTION}" = "*"]?adef,1) |
|---|
| | 314 | |
|---|
| | 315 | ; Got invalid option loop until the max |
|---|
| | 316 | ; |
|---|
| | 317 | exten => vmx,n,Set(LOOPCOUNT=$[${LOOPCOUNT} + 1]) |
|---|
| | 318 | exten => vmx,n,GotoIf($[${LOOPCOUNT} > ${VMX_LOOPS}]?toomany) |
|---|
| | 319 | exten => vmx,n,Playback(pm-invalid-option&please-try-again) |
|---|
| | 320 | exten => vmx,n,Goto(loopstart) |
|---|
| | 321 | |
|---|
| | 322 | ; tomany: to many invalid options, go to the specified destination |
|---|
| | 323 | ; |
|---|
| | 324 | exten => vmx,n(toomany),Noop(Too Many invalid entries, got to invalid dest) |
|---|
| | 325 | exten => vmx,n,Set(VMX_OPTS=${VMX_OPTS_LOOPS}) |
|---|
| | 326 | exten => vmx,n,GotoIf($["${DB_EXISTS(AMPUSER/${ARG1}/vmx/${MODE}/vmxopts/loops)}" = "0"]?chkloop) |
|---|
| | 327 | exten => vmx,n,Set(VMX_OPTS=${DB_RESULT}) |
|---|
| | 328 | exten => vmx,n(chkloop),GotoIf($["${DB_EXISTS(AMPUSER/${ARG1}/vmx/${MODE}/loopdest/ext)}" = "0"]?doloop) |
|---|
| | 329 | exten => vmx,n,Set(VMX_LOOPDEST_EXT=${DB_RESULT}) |
|---|
| | 330 | exten => vmx,n,GotoIf($["${DB_EXISTS(AMPUSER/${ARG1}/vmx/${MODE}/loopdest/context)}" = "0"]?looppri) |
|---|
| | 331 | exten => vmx,n,Set(VMX_LOOPDEST_CONTEXT=${DB_RESULT}) ;TODO make configurable per above |
|---|
| | 332 | exten => vmx,n(looppri),GotoIf($["${DB_EXISTS(AMPUSER/${ARG1}/vmx/${MODE}/loopdest/pri)}" = "0"]?doloop) |
|---|
| | 333 | exten => vmx,n,Set(VMX_LOOPDEST_PRI=${DB_RESULT}) ;TODO make configurable per above |
|---|
| | 334 | exten => vmx,n(doloop),Goto(${VMX_LOOPDEST_CONTEXT},${VMX_LOOPDEST_EXT},${VMX_LOOPDEST_PRI}) |
|---|
| | 335 | |
|---|
| | 336 | ; doopt: execute the valid option that was chosen |
|---|
| | 337 | ; |
|---|
| | 338 | exten => vmx,n(doopt),Noop(Got a valid option: ${DB_RESULT}) |
|---|
| | 339 | exten => vmx,n,Set(VMX_EXT=${DB_RESULT}) |
|---|
| | 340 | ; |
|---|
| | 341 | ; Special case, if this option was to go to voicemail, set options and go |
|---|
| | 342 | ; |
|---|
| | 343 | exten => vmx,n,GotoIf($["${VMX_EXT}" != "dovm"]?getdest) |
|---|
| | 344 | exten => vmx,n(vmxopts),Set(VMX_OPTS=${VMX_OPTS_DOVM}) |
|---|
| | 345 | exten => vmx,n,GotoIf($["${DB_EXISTS(AMPUSER/${ARG1}/vmx/${MODE}/vmxopts/dovm)}" = "0"]?vmxdovm) |
|---|
| | 346 | exten => vmx,n(vmxopts),Set(VMX_OPTS=${DB_RESULT}) |
|---|
| | 347 | exten => vmx,n(vmxdovm),goto(dovm,1) |
|---|
| | 348 | ; |
|---|
| | 349 | ; General case, setup the goto destination and go there (no error checking, its up to the GUI's to assure |
|---|
| | 350 | ; reasonable values |
|---|
| | 351 | ; |
|---|
| | 352 | exten => vmx,n(getdest),GotoIf($["${DB_EXISTS(AMPUSER/${ARG1}/vmx/${MODE}/${ACTION}/context)}" = "0"]?vmxpri) |
|---|
| | 353 | exten => vmx,n,Set(VMX_CONTEXT=${DB_RESULT}) |
|---|
| | 354 | exten => vmx,n(vmxpri),GotoIf($["${DB_EXISTS(AMPUSER/${ARG1}/vmx/${MODE}/${ACTION}/pri)}" = "0"]?vmxgoto) |
|---|
| | 355 | exten => vmx,n,Set(VMX_PRI=${DB_RESULT}) |
|---|
| | 356 | exten => vmx,n(vmxgoto),Goto(${VMX_CONTEXT},${VMX_EXT},${VMX_PRI}) |
|---|
| | 357 | |
|---|
| | 358 | ; If the required voicemail file is not present, then revert to normal voicemail |
|---|
| | 359 | ; behavior treating as if it was not set |
|---|
| | 360 | ; |
|---|
| | 361 | exten => vmx,file+101,Noop(File for mode: ${MODE} does not exist, going to normal voicemail) |
|---|
| | 362 | exten => vmx,n,Goto(s-${ARG2},1) |
|---|
| | 363 | |
|---|
| | 364 | ; Drop into voicemail either as a direct destination (in which case VMX_OPTS might be set to something) or |
|---|
| | 365 | ; if the user timed out or broke out of the loop then VMX_OPTS is always cleared such that an Allison |
|---|
| | 366 | ; message is played and the caller know's what is going on. |
|---|
| | 367 | ; |
|---|
| | 368 | exten => dovm,1,Noop(VMX Timeout - go to voicemail) |
|---|
| | 369 | exten => dovm,n,Voicemail(${ARG1}@${VMCONTEXT}|${VMX_OPTS}${VMGAIN}) ; no flags, so allison plays please leave ... |
|---|
| | 370 | exten => dovm,n,Goto(exit-${VMSTATUS},1) |
|---|