Solved

Asterisk GoToIf else question

Posted on 2013-01-14
8
563 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 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
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

The Zaptel people (www.zaptel.com) got kind of annoyed with the fact that they were getting bombarded with searches for the zaptel driver system for Asterisk (not to mention they own the trademark on zaptel). So, they kindly requested that Digium ch…
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…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

821 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