Solved

Asterisk GoToIf else question

Posted on 2013-01-14
8
542 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
Comment Utility
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
Comment Utility
I think that looks like it..., let me just see.
0
 

Author Comment

by:Silas2
Comment Utility
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
 

Author Comment

by:Silas2
Comment Utility
I'm on 1,8, can I use the exten=>textLable,priority,  in 1.8?
0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
LVL 15

Expert Comment

by:Phonebuff
Comment Utility
0
 

Author Comment

by:Silas2
Comment Utility
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
Comment Utility
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
Comment Utility
Sorry, you are right and i am indeed a numpty. True part before colon. just wasted an hour on that.....!
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

The point of this post is to give you a copy/paste installation solution to setting up Asterisk 1.6 on Ubuntu 9.04 (or similar) server. # Setup the system apt-get install subversion apt-get install make apt-get install linux-source kernel-p…
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…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

728 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now