?
Solved

Asterisk GoToIf else question

Posted on 2013-01-14
8
Medium Priority
?
580 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 1000 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
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 

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

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

Question has a verified solution.

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

How To Create Custom / Distinctive Ring Tones on Polycom Phones Purpose and Overview When creating a custom ring tone, you have simple aspirations: to make your phone cooler than everyone else's. Perhaps you need a louder ringer. Perhaps you w…
Implementing Avaya's One-X portal is pretty painless, until you want to deploy this to the Android and iPhone clients when these clients are outside of your network. The clients will also work within your local network. Here is our experience and so…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

770 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