-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtelephony.scxml
141 lines (130 loc) · 5.94 KB
/
telephony.scxml
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
<?xml version="1.0" encoding="UTF-8"?>
<scxml name="telephony" xmlns="http://www.w3.org/2005/07/scxml" version="1.0">
<script src="archive.js"></script>
<script src="playPick.js"></script>
<script src="performSearch.js"></script>
<state id="initial_default">
<transition target="waiting_for_initial_request"/>
</state>
<state id="waiting_for_initial_request">
<transition target="root_menu" event="call.start"/>
</state>
<state id="root_menu">
<state id="get_pick_input">
<onentry>
<log label="entering root_menu"/>
<send
type="http://scxml.io/httpLifecycle"
targetexpr="'scxml://response/' + _event.uuid"
event="response" >
<content><![CDATA[
<Response>
<Gather numDigits="1" action="number_received" method="GET">
{{_event.data.prependToResponse}}
<Say>Welcome to archive.org music service</Say>
<Say>Press 1 to listen to the archive dot org live music pick. Press 2 to search the archive dot org live music archive.</Say>
</Gather>
<Say>You didn't enter any input. Goodbye.</Say>
</Response>
]]></content>
</send>
</onentry>
<transition target="waiting_for_pick_input"/>
</state>
<state id="waiting_for_pick_input">
<transition target="playing_pick" event="call.number_received" cond="_event.data.params.Digits === '1'"/>
<transition target="searching" event="call.number_received" cond="_event.data.params.Digits === '2'"/>
<transition target="get_pick_input" event="call.number_received" cond="_event.data.params.Digits !== '1' && _event.data.params.Digits !== '2'">
<log label="Entered wrong number"/>
<script>
<![CDATA[
_event.data.prependToResponse = '<Say>I did not understand your response.</Say>';
]]>
</script>
</transition>
</state>
</state>
<state id="playing_pick">
<!-- TODO: move the logic in playPack into SCXML -->
<onentry>
<log label="entering playing_pick"/>
<script>
playPick.call(this, _event.uuid);
</script>
</onentry>
<!-- whatever we do, just return -->
<transition target="root_menu" event="*"/>
</state>
<state id="searching">
<datamodel>
<data id="searchNumber"/>
<data id="searchTerm"/>
</datamodel>
<state id="get_search_type_input">
<onentry>
<log label="entering get_search_type_input"/>
<send
type="http://scxml.io/httpLifecycle"
targetexpr="'scxml://response/' + _event.uuid"
event="response" >
<content><![CDATA[
<Response>
{{_event.data.prependToResponse}}
<Gather numDigits="1" action="number_received" finishOnKey="*" method="GET">
<Say>Press 1 to search for an artist. Press 2 to search for a title.</Say>
</Gather>
<Say>You didn't enter any input. Goodbye.</Say>
</Response>
]]></content>
</send>
</onentry>
<transition target="waiting_search_type_input"/>
</state>
<state id="waiting_search_type_input">
<transition target="receiving_search_input" event="call.number_received" cond="_event.data.params.Digits === '1' || _event.data.params.Digits === '2'">
<assign location="searchNumber" expr="_event.data.params.Digits"/>
</transition>
<transition target="root_menu" event="call.start"/>
<transition target="get_search_type_input" event="call.number_received" cond="_event.data.params.Digits !== '1' && _event.data.params.Digits !== '2'">
<log label="Entered wrong number"/>
<script>
<![CDATA[
_event.data.prependToResponse = '<Say>I did not understand your response.</Say>';
]]>
</script>
</transition>
</state>
</state>
<state id="receiving_search_input">
<onentry>
<send
type="http://scxml.io/httpLifecycle"
targetexpr="'scxml://response/' + _event.uuid"
event="response" >
<content><![CDATA[
<Response>
<Gather numDigits="3" action="number_received" method="GET">
<Say>Press the first three digits of the name to search for.</Say>
</Gather>
<Say>You didn't enter any input. Goodbye.</Say>
</Response>
]]></content>
</send>
</onentry>
<transition target="performing_search" event="call.number_received" cond="_event.data.params.Digits">
<assign location="searchTerm" expr="_event.data.params.Digits"/>
</transition>
</state>
<state id="performing_search">
<onentry>
<send event="wait" targetexpr="'scxml://response/' + _event.uuid" type="http://scxml.io/httpLifecycle"></send>
<script>
performSearch.call(this, searchNumber, searchTerm, _event.uuid);
</script>
</onentry>
<transition target="searching" event="call.search-complete" />
<transition target="searching" event="call.artist-not-found" />
<transition target="receiving_search_input" event="call.invalid-digits" />
<transition target="root_menu" event="*" />
</state>
</scxml>