Summary:ASTERISK-18918: Macro Exit via "Goto()" function, add support for text/named extensions
Reporter:Tim Strommen (tim.strommen)Labels:
Date Opened:2011-11-23 15:03:14.000-0600Date Closed:2011-12-01 14:40:01.000-0600
Versions: Frequency of
Environment:Ubuntu 11.04 (GNU/Linux 2.6.38-12-generic-pae i686)Attachments:
Description:I noticed while building a replacement call screening/find-me function (extra features and option above the canned screening/find-me tool), that exiting the macro via the Goto function does not support extention to be text/names.

For example, in the code:

${arg1) = User name for Find-me
${arg2} = User extension for Find-me
${arg3} = Incomming Caller-ID number (qualified as numerical before macro is called)
${arg4} = caller intro file suffix

exten => s,1,Verbose(Found user ${arg1})
exten => s,n,Wait(1)                                                            ; Allow cell phone user to place ohone to ear
exten => s,n,Playback(recording-warning)
exten => s,n(useroptions),Read(screenerselection,priv-callpending&/var/lib/asterisk/sounds/callerintro_${arg4}&priv-callee-options&priv-callee-options&screen_goodbye,1,n,1,5)
exten => s,n,Goto(${screenerselection},1)
exten => 1,1,Verbose(Caller accepted connecting callers)                        ; User accepted the incoming call
exten => 3,1,Verbose(Add caller-ID to priveledged list)                         ; Add user to priveledged list
exten => 3,n,Set(DB(priveledged/${arg3})=Added ${STRFTIME(${EPOCH},,%m-%d-%Y)})
exten => 3,n,Verbose(Connecting callers)
exten => 5,1,Verbose(Caller sent to voicemail)                                  ; User has sent the incoming call to voicemail
exten => 5,n,Playback(screen_goodbye)
exten => 5,n,Set(MACRO_RESULT=GOTO:force-voicemail^${arg2}^1)
exten => 7,1,Verbose(Caller is a telemarketer who needs to be blocked)          ; User has marked the incomming caller as a telemarketer to be blocked
exten => 7,n,Playback(screen_goodbye)
exten => 7,n,Set(MACRO_RESULT=GOTO:blocked-telemarketer^1999^1)
exten => 9,1,Verbose(Caller needs to be blacklisted)                            ; User has marked the incomming caller as a bad person to be blacklisted
exten => 9,n,Playback(screen_goodbye)
exten => 9,n,Set(MACRO_RESULT=GOTO:blocked-telemarketer^1888^1)
exten => i,1,Set(MACRO_RESULT=GOTO:force-voicemail^${arg2}^1)                   ; User did not select an option - may not have answered
exten => t,1,Set(MACRO_RESULT=GOTO:force-voicemail^${arg2}^1)                   ; User did not answer this line, send to voicemail.

I have had to use the code:
exten => 7,n,Set(MACRO_RESULT=GOTO:blocked-telemarketer^1999^1)
instead of:
exten => 7,n,Set(MACRO_RESULT=GOTO:blocked-telemarketer^new-telemarketer^1)

Allowing the macro to call a Goto() with a text extension would add a bit of security for internal extension functions (since a number keypad can't dial an ASCII string), and would allow for more clarity in dialplan code.
Comments:By: David Woolley (davidw) 2011-11-24 05:25:13.320-0600

I believe Macro is deprecated.  If it isn't, you will need to provide a patch against the trunk version.

By: Tim Strommen (tim.strommen) 2011-11-24 23:46:03.434-0600

Macro() is a fundamental tool within the Asterisk engine which allows programmers to abstract complext and frequently used functions.  It is still current even up to Astersik 10...  https://wiki.asterisk.org/wiki/spaces/flyingpdf/pdfpageexport.action?pageId=19005699&ei=BCrPTsrWIaWriAL8g6z8Cw&usg=AFQjCNFHwXqZ2hn9pNTMK-pbgXrDScMRFw

I am not a coder, and I am not familiar with the compilation tools for Astersik.  Cant help more than reporting bugs and verifying fixes...

By: David Woolley (davidw) 2011-11-25 06:01:02.759-0600

Features requests are no longer submitted to or accepted through the issue tracker. Features requests are openly discussed on the mailing lists [1] and Asterisk IRC channels and made note of by Bug Marshals. [1] http://www.asterisk.org/support/mailing-lists

Gosub should be used instead of Macro.

By: Tim Strommen (tim.strommen) 2011-11-30 19:16:25.220-0600

Dail() option "M" does not use GoSub, it uses Macro.  Macro is most important when the system is spawning a new call and has yet to connect the two calls to a single conversation - as an example, when screening a caller...  like in my use case.  GoSub doesn't do what Macro does, I hope you're not getting rid of Macro() without porting over all of its functionality.

Will continue to use Macro(), and will send an email to the Bug Marshals.  Don't close this.

By: David Woolley (davidw) 2011-12-01 05:53:12.236-0600

U option.

By: Leif Madsen (lmadsen) 2011-12-01 14:39:53.074-0600

Right, as David has pointed out, you should be use the GoSub() functionality for what you're building. It is designed for exactly what you're describing.