Skip to Content
Asterisk: The Future of Telephony, 2nd Edition
book

Asterisk: The Future of Telephony, 2nd Edition

by Jim Van Meggelen, Jared Smith, Leif Madsen
August 2007
Intermediate to advanced
608 pages
20h 33m
English
O'Reilly Media, Inc.
Content preview from Asterisk: The Future of Telephony, 2nd Edition

Name

GotoIf() — Conditionally goes to the specified priority

Synopsis

GotoIf(condition?label1:label2)

Sends the call to label1 if condition is true or to label2 if condition is false. Either label1 or label2 may be omitted (in that case, we just don’t take the particular branch), but not both.

A label can be any one of the following:

  • A priority, such as 10

  • An extension and a priority, such as 123,10

  • A context, extension, and priority, such as incoming,123,10

  • A named priority within the same extension, such as passed

Each type of label is explained in this example:

[globals]
; set TEST to something else besides 101 to see what GotoIf()
; does when the condition is false
TEST=101
;
[incoming]
; set a variable
; go to priority 10 if ${TEST} is 101, otherwise go to priority 20
exten => 123,1,GotoIf($[ ${TEST} = 101 ]?10:20)
exten => 123,10,Playback(the-monkeys-twice)
exten => 123,20,Playback(tt-somethingwrong)
;
; same thing as above, but this time we'll specify an extension
; and a priority for each label
exten => 124,1,GotoIf($[ ${TEST} = 101 ]?123,10:123,20)
;
; same thing as above, but these labels have a context, extension, and
; priority
exten => 125,1,GotoIf($[ ${TEST} = 101 ]?incoming,123,10:incoming,123,20)
;
; same thing as above, but this time we'll go to named priorities
exten => 126,1,GotoIf($[ ${TEST} = 101 ]?passed:failed)
exten => 126,15(passed),Playback(the-monkeys-twice)
exten => 126,25(failed),Playback(the-monkeys-twice)
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Asterisk: The Future of Telephony

Asterisk: The Future of Telephony

Jim Van Meggelen, Jared Smith, Leif Madsen
Switching to VoIP

Switching to VoIP

Theodore Wallingford

Publisher Resources

ISBN: 9780596510480Errata Page