Link to home
Start Free TrialLog in
Avatar of Muhajreen
Muhajreen

asked on

Nesting Variables in Asterisk dialplan

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?
ASKER CERTIFIED SOLUTION
Avatar of Member_2_1968385
Member_2_1968385
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Muhajreen
Muhajreen

ASKER

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.
Sorry for the mistake, the verbose is:

Set("SIP/gsmgw-00001184", "emailDest=GSMh")
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' )



SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Remember that ${EXTEN} always evaluates the current extension....
Thank you both ! Asterisk, EE and you are great !