-
Notifications
You must be signed in to change notification settings - Fork 1
/
dialplan.rb
48 lines (40 loc) · 1.35 KB
/
dialplan.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
Voipms = 'SIP/%s@voipms'
Nufone = 'SIP/%s@nufone'
Vitelity = 'SIP/%s@vitelity'
Mobile = 1_409_767_2813
Roomie = 1_415_412_5674
MyDesk = 1_415_524_4444
desk {
extension_length = extension.to_s.length
peer_extension = case extension_length
when 7 : "1415#{extension}"
when 10 : "1#{extension}"
when 11 : extension
else
+invalid
end
dial Vitelity % peer_extension, :caller_id => MyDesk
dial Voipms % peer_extension, :caller_id => MyDesk if last_dial_unsuccessful?
dial Nufone % peer_extension, :caller_id => MyDesk if last_dial_unsuccessful?
}
invalid {
play 'invalid'
}
direct_dial {
dial Vitelity % extension, :caller_id => MyDesk
}
from_trunk {
case extension
when 415_524_4444, 650_305_2000, 409_291_4773, 44_20_3051_4843, # <-- Voip.ms
415_963_3703 # <-- Vitelity
dial "SIP/jay-desk-650&SIP/jay-desk-601&SIP/jay-desk-601-2",
:for => 15.seconds, :caller_id => callerid
alternatives = [Voipms % Mobile, Nufone % Mobile]
# Try roommate as a middle-step if it's someone at the gate trying to get in.
alternatives.insert(1, Voipms % Roomie) if calleridname == 'EUREKA GARDENS'
until last_dial_successful? || alternatives.empty?
ahn_log 'Trying cell phone.'
dial alternatives.shift, :caller_id => callerid, :for => 15.seconds
end
end
}