[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Asterisk GoToIf else question

Posted on 2013-01-14
8
Medium Priority
?
593 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
  • 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
Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

 

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

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!

Question has a verified solution.

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

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 …
Why do some people recommend buying business VoIP from an ISP? What are the benefits to my company? What are the costs?
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Screencast - Getting to Know the Pipeline
Suggested Courses

831 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