@onereach/step-voice 4.0.3 → 4.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dst/Initiate Call.js +20 -30
- package/package.json +1 -1
package/dst/Initiate Call.js
CHANGED
|
@@ -14,7 +14,7 @@ class InitiateCall extends voice_1.default {
|
|
|
14
14
|
return undefined;
|
|
15
15
|
}
|
|
16
16
|
async runStep() {
|
|
17
|
-
const { from: botNumber, endUserNumber, sipHost, sipUser, sipPassword, timeout, headers,
|
|
17
|
+
const { channelId = uuid.v4(), from: botNumber, endUserNumber, sipHost, sipUser, sipPassword, timeout, headers, enableSpoofCallerId, spoofCallerId } = this.data;
|
|
18
18
|
const originateTimeout = timestring(`${timeout || 30} sec`, 'ms'); // timeout or 30 seconds
|
|
19
19
|
const customHeaders = _.reduce(headers, (memo, header) => {
|
|
20
20
|
memo[header.name] = `${header.value}`;
|
|
@@ -25,7 +25,7 @@ class InitiateCall extends voice_1.default {
|
|
|
25
25
|
target: 'provider',
|
|
26
26
|
name: 'out/voice/originate',
|
|
27
27
|
params: {
|
|
28
|
-
id:
|
|
28
|
+
id: channelId,
|
|
29
29
|
from: botNumber,
|
|
30
30
|
to: endUserNumber,
|
|
31
31
|
headers: customHeaders,
|
|
@@ -50,7 +50,7 @@ class InitiateCall extends voice_1.default {
|
|
|
50
50
|
target: 'provider',
|
|
51
51
|
name: 'out/voice/originate',
|
|
52
52
|
params: {
|
|
53
|
-
id:
|
|
53
|
+
id: channelId,
|
|
54
54
|
from: botNumber,
|
|
55
55
|
to: endUserNumber,
|
|
56
56
|
headers: customHeaders,
|
|
@@ -71,13 +71,26 @@ class InitiateCall extends voice_1.default {
|
|
|
71
71
|
}
|
|
72
72
|
});
|
|
73
73
|
}
|
|
74
|
-
|
|
74
|
+
if (!this.session.key) {
|
|
75
|
+
const sessionTimeoutMs = timestring(`${this.data.sessionTimeout} min`, 'ms') || defaultSessionTimeout;
|
|
76
|
+
await this.session.start({
|
|
77
|
+
key: channelId,
|
|
78
|
+
timeout: sessionTimeoutMs,
|
|
79
|
+
reporting: {
|
|
80
|
+
settingsKey: 'session',
|
|
81
|
+
startedBy: 'Bot',
|
|
82
|
+
sessionType: 'Phone'
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
await this.startConversation({ id: channelId }, { events: [] });
|
|
87
|
+
// await this.setDataOut()
|
|
75
88
|
this.gotoState('waitForCall');
|
|
76
89
|
}
|
|
77
90
|
async waitForCall() {
|
|
78
|
-
const { from: botNumber, endUserNumber, isAMD, asr, tts
|
|
79
|
-
const { id:
|
|
80
|
-
this.triggers.once(`in/voice/${
|
|
91
|
+
const { from: botNumber, endUserNumber, isAMD, asr, tts } = this.data;
|
|
92
|
+
const { id: channelId } = await this.getDataOut();
|
|
93
|
+
this.triggers.once(`in/voice/${channelId}/event`, async (event) => {
|
|
81
94
|
switch (event.params.type) {
|
|
82
95
|
case 'is_flow_ready': {
|
|
83
96
|
// TODO this.exitFlow({is_ready : true}) should be enough
|
|
@@ -102,18 +115,6 @@ class InitiateCall extends voice_1.default {
|
|
|
102
115
|
};
|
|
103
116
|
delete channel.from;
|
|
104
117
|
delete channel.to;
|
|
105
|
-
if (!this.session.key) {
|
|
106
|
-
const sessionTimeoutMs = timestring(`${sessionTimeout} min`, 'ms') || defaultSessionTimeout;
|
|
107
|
-
await this.session.start({
|
|
108
|
-
key: channel.id,
|
|
109
|
-
timeout: sessionTimeoutMs,
|
|
110
|
-
reporting: {
|
|
111
|
-
settingsKey: 'session',
|
|
112
|
-
startedBy: 'Bot',
|
|
113
|
-
sessionType: 'Phone'
|
|
114
|
-
}
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
118
|
await this.startConversation(channel, {
|
|
118
119
|
events: { [`in/voice/${channel.id}/event`]: {} }
|
|
119
120
|
});
|
|
@@ -143,17 +144,6 @@ class InitiateCall extends voice_1.default {
|
|
|
143
144
|
return this.exitStep('success');
|
|
144
145
|
}
|
|
145
146
|
case 'error': {
|
|
146
|
-
if (!this.session.key) {
|
|
147
|
-
await this.session.start({
|
|
148
|
-
key: this.thread.request.requestId,
|
|
149
|
-
timeout: sessionTimeoutMs,
|
|
150
|
-
reporting: {
|
|
151
|
-
settingsKey: 'session',
|
|
152
|
-
startedBy: 'Bot',
|
|
153
|
-
sessionType: 'Phone'
|
|
154
|
-
}
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
147
|
const error = _.get(event, 'params.error.originateStatus');
|
|
158
148
|
const errorChannel = {
|
|
159
149
|
botNumber,
|