Is It Possible?

Hi ,

I have cisco 7940 2-line phone working with Asterisk. I configured line 1 with extension 2138, line 2 with ext:3138. both extensions are working fine seperately.

Now i need following logic in extensions.conf

when line1 is busy, calls should ring on line2. if line2 also busy, then goto voicemail.

my current configuration is like below:

exten => _2138,1,Dial(SIP/${2138},15,r)
exten => _2138,2,Voicemail(u${2138})
exten => _2138,3,Hangup

exten => _3138,1,Dial(SIP/${3138},15,r)
exten => _3138,2,Voicemail(u${3138})
exten => _3138,3,Hangup

Can some one help me to write the code.

Thanks.

exten => 101,1,Dial(SIP/101,15)
exten => 101,n,Dial(SIP/301,15)
exten => 101,n,Voicemail(u${101})
exten => 101,n,Hangup

this SHOULD work…

EDIT: i just set up something similar, and when the phones are not registered, it jumps straight to VM.

that should work fine for you.

Hi ,
I have macro for my extensions. how do i edit MACRO to pass line sip-extension as argument. I tried some like below but, did not worked for me.

assume my ARG1 is 101, when 101 is busy, the call should go to 201 and then to VM.

[macro-ext]
exten => s,1,Dial(${ARG1},15)
exten => s,1,Dial(${ARG1+1000},15)
exten => s,2,Voicemail(u${ARG2})
exten => s,3,Hangup

Please help.

thanks
sekhar.

thats an interesting one.

If you are using all SIP lines (no iax2 or zap) you could do

exten => s,1,Dial(SIP/${ARG1},15)
to add +101 you need to put it as an expression, i THINK that would be $[${ARG1} + “101”] but i could be wrong. check voip-info.org

(IE
exten => s,2,Dial(SIP/$[${ARG1} + “101”],20)

Hi IronHelix,

i tried calling from 2181 to 2138
It did not worked out, see below attached error


-- Executing Macro("SIP/2181-09e77ea0", "ext|SIP/2138|2138") in new stack
-- Executing Dial("SIP/2181-09e77ea0", "SIP/2138|15") in new stack
-- Called 2138
-- SIP/2138-09e7dbd8 is ringing
-- Nobody picked up in 15000 ms

Aug 27 18:59:01 WARNING[3673]: ast_expr2.y:843 op_div: non-numeric argument
– Executing Dial(“SIP/2181-09e77ea0”, “0|20”) in new stack
Aug 27 18:59:01 WARNING[3673]: app_dial.c:1024 dial_exec_full: Dial argument takes format (technology/[device:]number1)
== Spawn extension (macro-ext, s, 2) exited non-zero on ‘SIP/2181-09e77ea0’ in macro ‘ext’
== Spawn extension (macro-ext, s, 2) exited non-zero on ‘SIP/2181-09e77ea0’

paste what you are currently using as the macro and the relevant other parts of extensions.conf to get that?

Hi IronHelix,
Below is debug output & .conf files

-- Executing Macro("SIP/2181-090f8770", "ext|SIP/2138|2138") in new stack
-- Executing Answer("SIP/2181-090f8770", "") in new stack
-- Executing SetMusicOnHold("SIP/2181-090f8770", "default") in new stack
-- Executing Dial("SIP/2181-090f8770", "SIP/2138|15") in new stack
-- Called 2138
-- SIP/2138-090fd438 is ringing
-- Nobody picked up in 15000 ms
-- Executing VoiceMail("SIP/2181-090f8770", "u2138") in new stack
-- Playing '/var/spool/asterisk/voicemail/default/2138/temp' (language 'en')
-- Playing 'vm-intro' (language 'en')
-- Playing 'beep' (language 'en')
-- Recording the message
-- x=0, open writing:  /var/spool/asterisk/voicemail/default/2138/tmp/dxX8TR format: wav49, 0x9081418
-- x=1, open writing:  /var/spool/asterisk/voicemail/default/2138/tmp/dxX8TR format: gsm, 0x907cc18
-- x=2, open writing:  /var/spool/asterisk/voicemail/default/2138/tmp/dxX8TR format: wav, 0x907ec68
-- User hung up
-- Recording was 3 seconds long but needs to be at least 5 - abandoning

== Spawn extension (macro-ext, s, 4) exited non-zero on ‘SIP/2181-090f8770’ in macro ‘ext’
== Spawn extension (macro-ext, s, 4) exited non-zero on ‘SIP/2181-090f8770’

[macro-ext]
exten => s,1,Answer
exten => s,2,SetMusicOnHold(default)
exten => s,3,Dial(${ARG1},15)
exten => s,3,Dial(${ARG1}+“1000”,15)
exten => s,4,Voicemail(u${ARG2})
exten => s,5,Hangup

also tried:
[macro-ext]
exten => s,1,Answer
exten => s,2,SetMusicOnHold(default)
exten => s,3,Dial(${ARG1},15)
exten => s,3,Dial(${ARG1}+1000,15)
exten => s,4,Voicemail(u${ARG2})
exten => s,5,Hangup

[extensions]
;User Extensions
exten => _21XX,1,Macro(ext,SIP/${EXTEN},${EXTEN})

To make asterisk perform a calculation, you have to form it correctly…

Dial(${ARG1}+1000,15)

replace with

Dial(SIP/$[${ARG1} + “1000”],20)

to separate that-
$[${ARG1} + “1000”] becomes

${ARG1} + “1000” enclosed by $[ ], which tell asterisk that logic is going to be required.

Hi IronHelix,

I want to make sure that the express is working fine, so, i changed my macro to

[macro-ext]
exten => s,1,Answer
exten => s,2,SetMusicOnHold(default)
;exten => s,3,Dial(${ARG1},15) Commented this Line
exten => s,3,Dial($[${ARG1} + “1000”],10)
exten => s,4,Voicemail(u${ARG2})
exten => s,5,Hangup

So, when i dial 2138, the call is suppose to go 2138+1000=3138. 3138 is registered SIP Phone.
but i got below error.

-- Executing Macro("SIP/2181-b7906830", "ext|SIP/2138|2138") in new stack
-- Executing Answer("SIP/2181-b7906830", "") in new stack
-- Executing SetMusicOnHold("SIP/2181-b7906830", "default") in new stack

Sep 2 00:47:16 WARNING[4709]: ast_expr2.y:843 op_div: non-numeric argument
– Executing Dial(“SIP/2181-b7906830”, “0|10”) in new stack
Sep 2 00:47:16 WARNING[4709]: app_dial.c:1024 dial_exec_full: Dial argument takes format (technology/[device:]number1)
== Spawn extension (macro-ext, s, 3) exited non-zero on ‘SIP/2181-b7906830’ in macro ‘ext’
== Spawn extension (macro-ext, s, 3) exited non-zero on ‘SIP/2181-b7906830’
– Incoming call: Got SIP response 500 “Server Internal Error” back from 10.250.10.201

Some where i read a conditional jump satements like exten => s,BUSY then GOTO ARG2 something likes this.
But first the mathematical calcualation should work to get this.

OR, is there a better way to automatically dial on to second Line in CISCO 79XX Phones?

Your help is really appreciated.

Have a nice long weekend.

ah i see the problem. ${ARG1} is ‘SIP/xxxx’, including the SIP/.

try this
exten => s,3,Dial(SIP/$[${ARG1:4} + “1000”],10)

${ARG1:4} strips the first 4 chars (SIP/) which leaves it with an exten #. The SIP/ is added again in the beginning.

Hope that helps!

Hi IronHelix,

Below is the debug output.

-- Executing Macro("SIP/2181-082f09b8", "ext|2138|2138") in new stack
-- Executing Answer("SIP/2181-082f09b8", "") in new stack
-- Executing SetMusicOnHold("SIP/2181-082f09b8", "default") in new stack

Sep 5 21:43:54 WARNING[6090]: ast_expr2.fl:183 ast_yyerror: ast_yyerror(): syntax error: syntax error, unexpected TOK_PLUS, expecting TOK_MINUS or TOK_COMPL or TOK_LP or TOKEN; Input:
+“1000”
^
Sep 5 21:43:54 WARNING[6090]: ast_expr2.fl:187 ast_yyerror: If you have questions, please refer to doc/README.variables in the asterisk source.
– Executing Dial(“SIP/2181-082f09b8”, “SIP/0|10”) in new stack
Sep 5 21:43:54 WARNING[6090]: chan_sip.c:1989 create_addr: No such host: 0
Sep 5 21:43:54 NOTICE[6090]: app_dial.c:1056 dial_exec_full: Unable to create channel of type ‘SIP’ (cause 3 - No route to destination)
== Everyone is busy/congested at this time (1:0/0/1)
– Executing VoiceMail(“SIP/2181-082f09b8”, “u2138”) in new stack
– Playing ‘vm-theperson’ (language ‘en’)
– Playing ‘digits/2’ (language ‘en’)
– Playing ‘digits/1’ (language ‘en’)
– Playing ‘digits/3’ (language ‘en’)
– Playing ‘digits/8’ (language ‘en’)
– Playing ‘vm-isunavail’ (language ‘en’)
– Playing ‘vm-intro’ (language ‘en’)
== Spawn extension (macro-ext, s, 4) exited non-zero on ‘SIP/2181-082f09b8’ in macro ‘ext’
== Spawn extension (macro-ext, s, 4) exited non-zero on 'SIP/2181-082f09b8’
astpbx*CLI>

below is my changed macro. I commented one line just to make sure the calculation is happening, but it seems still it needs some thing more.

[macro-ext]
exten => s,1,Answer
exten => s,2,SetMusicOnHold(default)
;exten => s,3,Dial(SIP/${ARG1},15)
exten => s,3,Dial(SIP/$[${ARG1:4}+“1000”],10)
exten => s,4,Voicemail(u${ARG2})
exten => s,5,Hangup


Thanks
Sekhar.

try removing the quotes from the “1000” so its just 1000…