Solved

Nesting Variables in Asterisk dialplan

Posted on 2011-03-03
7
698 Views
Last Modified: 2012-06-21
Hello experts,

In my asterisk dialplan, when user dials extension 1, sip trunk (GSM1) should be dialled, and an email should be sent to (Email1) address. The same with extension 2,3 and 4

I wrote this in my dialplan:

[gsmplan]

exten => _[1234],1,dial(SIP/siptrunk/GSM${EVAL(${EXTEN})},60)

exten => h,1,System(/usr/local/bin/sendEmail -f me@domain.com -t Email${EVAL(${Email1})} -m 'This is a test message' )

In the verbose, I am having:

Executing [1@gsmplan:1] Dial("SIP/user-0000064b", "SIP/siptrunk/GSM1,60") in new stack

The problem is that it's dialing GSM1 while it should be replaced with it's variable value.

Any help?
0
Comment
Question by:Muhajreen
  • 3
  • 3
7 Comments
 
LVL 19

Accepted Solution

by:
feptias earned 300 total points
ID: 35096703
Do you mean that you have a variable called GSM1??

If so, you have made two mistakes. First, the GSM must be within the EVAL brackets. Second, you are trying to use the Dahdi device format as the first argument to the Dial command, for a SIP call. SIP calls use a slightly different format for that first argument - for details see the section "Using the Dial Command with SIP Channels" at this link:
http://www.voip-info.org/wiki/index.php?page=Asterisk+SIP+channels

Try this:
    exten => _[1234],1,dial(SIP/${GSM${EXTEN}}@siptrunk,60)
 ...or this
    exten => _[1234],1,dial(SIP/${EVAL(GSM${EXTEN})}@siptrunk,60)

0
 

Author Comment

by:Muhajreen
ID: 35109912
Thank you for your helpful post ! I was waiting for your response :)

Actually this worked perfectly:

exten => _[1234],1,dial(SIP/${GSM${EXTEN}}@siptrunk,60)

But this didn't work:

exten => h,1,Set(emailDest=${EVAL(Email${EXTEN})})
exten => h,2,System(/usr/local/bin/sendEmail -f me@domain.com -t ${emailDest} -m 'This is a test message' )

In console, I am getting: Set("SIP/gsmgw-00001184", "smsDest=GSMh")

Here are two problems: GSM and h.

Thank you in advance.
0
 

Author Comment

by:Muhajreen
ID: 35109945
Sorry for the mistake, the verbose is:

Set("SIP/gsmgw-00001184", "emailDest=GSMh")
0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 25

Expert Comment

by:Ron M
ID: 35109996
Try this....
If you accept this as part of your solution, please make sure Feptias get's points and best answer.

exten => _[1234],1,dial(SIP/${GSM${EXTEN}}@siptrunk,60)

exten => _[1234],n,Set(numdialed=${EXTEN})

exten => h,1,Set(emailDest=Email${numdialed})
exten => h,2,System(/usr/local/bin/sendEmail -f me@domain.com -t ${emailDest} -m 'This is a test message' )



0
 
LVL 25

Assisted Solution

by:Ron M
Ron M earned 200 total points
ID: 35110005
Wait... sorry I meant to reverse the first two lines...

exten => _[1234],1,Set(numdialed=${EXTEN})
exten => _[1234],n,dial(SIP/${GSM${EXTEN}}@siptrunk,60)

exten => h,1,Set(emailDest=Email${numdialed})
exten => h,2,System(/usr/local/bin/sendEmail -f me@domain.com -t ${emailDest} -m 'This is a test message' )

0
 
LVL 25

Expert Comment

by:Ron M
ID: 35110019
Remember that ${EXTEN} always evaluates the current extension....
0
 

Author Closing Comment

by:Muhajreen
ID: 35110184
Thank you both ! Asterisk, EE and you are great !
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

There are no good configuration guides for HP-H3C router to LYNC on the web. :( Big statement, but we havent been able to find one yet. We did find the following document useful, but the information was not enough to use H3C router for use as a L…
What do we know about Legacy Video Conferencing? - Full IT support needed! - Complicated systems at outrageous prices! - Intense training required! Highfive believes we need to embrace a new alternative.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now