Nesting Variables in Asterisk dialplan

Posted on 2011-03-03
Medium Priority
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:


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?
Question by:Muhajreen
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
LVL 19

Accepted Solution

feptias earned 1200 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:

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


Author Comment

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.

Author Comment

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

Set("SIP/gsmgw-00001184", "emailDest=GSMh")
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

LVL 25

Expert Comment

by:Ron Malmstead
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' )

LVL 25

Assisted Solution

by:Ron Malmstead
Ron Malmstead earned 800 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' )

LVL 25

Expert Comment

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

Author Closing Comment

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

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
This is a step by step guide on creating single number reach (mobility) for Cisco Call Manager.  After configuring this when someone calls your deskphone after 3-4 rings your cell phone will start to ring.  If you do not answer the call will go to y…
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, f…

777 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