Solved

Asterisk GoToIf else question

Posted on 2013-01-14
8
573 Views
Last Modified: 2013-01-22
I can't get my head round the asterisk gotoif/else. I'm using the 'n' numbering, but i want to do something like this:
switch (MyVar)
{
    case 1: exten => s,n,(dial1),Dial(SIP/VoIPProvider1/${dialednum},30,g)
    case 2: exten => s,n,(dial2),Dial(SIP/VoIPProvider2/${dialednum},30,g) 
    case 2: exten => s,n,(dial3),Dial(SIP/VoIPProvider3/${dialednum},30,g)
}
carry on with lots more stuff..

Open in new window

i.e. i don't want to execute a hangup() after each branch, i have a lot of other stuff common to case 1,2,3 i want to add.
0
Comment
Question by:Silas2
[X]
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
  • 5
  • 3
8 Comments
 
LVL 15

Accepted Solution

by:
Phonebuff earned 250 total points
ID: 38776942
I am not totally sure I understand your question but does this snip it help --

[case-like-structure]

exten =>  s,n, GoToIf(MyVar = 1? Provider1,1)
exten =>  s,n, GotoIf(MyVar  = 2? Provider2,1)
extern=>  s,n,GoToIf(MyVAr  = 3? Provider3,1)
extern => s,n,playback(silence/2&sorry-cant-let-you-do-that)
extern=>  s,n,HangUp()

extern => Provider1,1,NoOP()
extern => Provider1,2,Dial(SIP/VoIPProvider1/${dialednum},30,g)
extern => Provider1,3,GoTo(Folowup,1)

extern => Provider2,1,NoOP()
extern => Provider2,2,Dial(SIP/VoIPProvider1/${dialednum},30,g)
extern => Provider2,3,GoTo(Folowup,1)

extern => Provider3,1,NoOP()
extern => Provider3,2,Dial(SIP/VoIPProvider1/${dialednum},30,g)
extern => Provider3,3,GoTo(Folowup,1)

extern => FollowUp,1,NoOP()
extern => FollowUp,n,PlayBack(silence/2,Well-You-Got-Here-Now What)
extern => FollowUp,n,Hangup()

Open in new window

0
 

Author Comment

by:Silas2
ID: 38777882
I think that looks like it..., let me just see.
0
 

Author Comment

by:Silas2
ID: 38779367
I'm doing as you suggested, but I'm getting " Sent to invalid extension 'Provider1'
here's my extensionts.conf:
exten => s,n, GoToIf(${STAT(e,/home/silas/csharp/DialPlanBranches/B1/ChooseMe.txt)}=1 ? Provider1,1 )
exten => s,n, GoToIf(${STAT(e,/home/silas/csharp/DialPlanBranches/B2/ChooseMe.txt)}=1 ? Provider2,1 )
exten => s,n, GoToIf(${STAT(e,/home/silas/csharp/DialPlanBranches/B3/ChooseMe.txt)}=1 ? Provider3,1 )
exten => s,n, GoToIf(${STAT(e,/home/silas/csharp/DialPlanBranches/B4/ChooseMe.txt)}=1 ? Provider4,1 )
exten => s,n, GoToIf(${STAT(e,/home/silas/csharp/DialPlanBranches/B5/ChooseMe.txt)}=1 ? Provider5,1 )

exten => Provider1,1,Dial(SIP/VoIPProvider/${dialednum},30,g)
exten => Provider2,1,Dial(SIP/VoIPProviderSipgate/${dialednum},30,g)
exten => Provider3,1,Dial(SIP/VoIPProvider/${dialednum},30,g)
exten => Provider4,1,Dial(SIP/VoIPProvider/${dialednum},30,g)
exten => Provider5,1,Dial(SIP/VoIPProvider/${dialednum},30,g)

Open in new window

0
Technology Partners: 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!

 

Author Comment

by:Silas2
ID: 38780045
I'm on 1,8, can I use the exten=>textLable,priority,  in 1.8?
0
 
LVL 15

Expert Comment

by:Phonebuff
ID: 38780674
0
 

Author Comment

by:Silas2
ID: 38783083
I don't want to sound ungrateful, but your code:
extern=>  s,n,GoToIf(MyVAr  = 3? Provider3,1)

Open in new window

the syntax is slightly wrong!!! it should be:

extern=>  s,n,GoToIf(MyVAr  = 3?: Provider3,1)
extra colon when only one if-then!!!

Open in new window

That was throwing my dialplan out. I am very grateful for seeing the 'named extenstion' way of branching, and you do remember things a bit better when you have to work for them!
0
 
LVL 15

Expert Comment

by:Phonebuff
ID: 38784794
Sorry,

    I haven't had to write a dial plan context in a few months. Was working from memory.

    Glad you got it working.

    =============
0
 

Author Comment

by:Silas2
ID: 38806760
Sorry, you are right and i am indeed a numpty. True part before colon. just wasted an hour on that.....!
0

Featured Post

Independent Software Vendors: 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!

Question has a verified solution.

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

So you think no one can listen in on your VOIP conversations, eh? Well... if you haven't setup Secure Real Time Transport (SRTP), your voice communications can be hacked into by just about anyone! First, let's talk about the intended audience for…
I recently purchased a Bluetooth headset called the Music Jogger (model BSH10). The control buttons on it look like this: One of my goals is to use it as the microphone and speakers for Skype calls. In that respect, it works well. However, I …
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

689 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