Solved

Nesting Variables in Asterisk dialplan

Posted on 2011-03-03
7
705 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
How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

 
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' )



0
 
LVL 25

Assisted Solution

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Outsource Your Fax Infrastructure to the Cloud (And come out looking like an IT Hero!) Relative to the many demands on today’s IT teams, spending capital, time and resources to maintain physical fax servers and infrastructure is not a high priority.
Moving your enterprise fax infrastructure from in-house fax machines and servers to the cloud makes sense — from both an efficiency and productivity standpoint. But does migrating to a cloud fax solution mean you will no longer be able to send or re…
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…
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…

809 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