@onereach/step-voice 7.0.2-VOIC1438.12 → 7.0.2-VOIC1438.14
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/MeetOps.d.ts +2 -0
- package/dst/MeetOps.js +65 -8
- package/dst/Send DTMF.js +1 -1
- package/package.json +1 -1
package/dst/MeetOps.d.ts
CHANGED
|
@@ -31,6 +31,8 @@ export default class MeetOps extends VoiceStep<MeetOpsInput, MeetOpsOutput, Call
|
|
|
31
31
|
runStep(): Promise<void>;
|
|
32
32
|
onAwake(): Promise<void>;
|
|
33
33
|
waitForJoin(): Promise<void>;
|
|
34
|
+
private onHangup;
|
|
35
|
+
private onError;
|
|
34
36
|
private onCall;
|
|
35
37
|
originate(call: IVoiceCall): Promise<void>;
|
|
36
38
|
}
|
package/dst/MeetOps.js
CHANGED
|
@@ -40,14 +40,19 @@ class MeetOps extends voice_1.default {
|
|
|
40
40
|
async waitForJoin() {
|
|
41
41
|
const call = await this.fetchData();
|
|
42
42
|
this.triggers.once(`in/voice/${call.id}/event`, async (event) => {
|
|
43
|
+
this.log.debug('call event type:', event.params.type);
|
|
44
|
+
this.log.debug('call event:', event);
|
|
43
45
|
switch (event.params.type) {
|
|
44
|
-
case 'is_flow_ready':
|
|
46
|
+
case 'is_flow_ready':
|
|
45
47
|
return this.exitFlow({ is_ready: true });
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
return this.
|
|
50
|
-
|
|
48
|
+
case 'call':
|
|
49
|
+
return await this.onCall(event, call);
|
|
50
|
+
case 'hangup':
|
|
51
|
+
return await this.onHangup(event, call);
|
|
52
|
+
case 'error':
|
|
53
|
+
return await this.onError(event);
|
|
54
|
+
default:
|
|
55
|
+
return this.exitFlow();
|
|
51
56
|
}
|
|
52
57
|
});
|
|
53
58
|
this.triggers.otherwise(async () => {
|
|
@@ -55,6 +60,53 @@ class MeetOps extends voice_1.default {
|
|
|
55
60
|
await this.originate(call);
|
|
56
61
|
});
|
|
57
62
|
}
|
|
63
|
+
async onHangup(event, call) {
|
|
64
|
+
const { handleCancel } = this.data;
|
|
65
|
+
await this.handleHangup(call);
|
|
66
|
+
if (handleCancel && event.params.error?.name === 'CancelError') {
|
|
67
|
+
return this.exitStep('cancel');
|
|
68
|
+
}
|
|
69
|
+
return this.throwError(event.params.error ?? {
|
|
70
|
+
name: 'HangupError',
|
|
71
|
+
message: 'unpexpected hangup during init call'
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
async onError(event) {
|
|
75
|
+
const { from: botNumber, endUserNumber } = this.data;
|
|
76
|
+
const error = event.params.error;
|
|
77
|
+
const errorStatus = error?.originateStatus ?? 'UNKNOWN';
|
|
78
|
+
const errorCall = {
|
|
79
|
+
botNumber,
|
|
80
|
+
endUserNumber
|
|
81
|
+
};
|
|
82
|
+
switch (errorStatus) {
|
|
83
|
+
case 'USER_BUSY':
|
|
84
|
+
await this.transcript(errorCall, {
|
|
85
|
+
action: 'Call Busy',
|
|
86
|
+
actionFromBot: true
|
|
87
|
+
});
|
|
88
|
+
await this.updateData();
|
|
89
|
+
return this.exitStep('busy', errorCall);
|
|
90
|
+
case 'NO_ANSWER':
|
|
91
|
+
case 'NO_USER_RESPONSE':
|
|
92
|
+
await this.transcript(errorCall, {
|
|
93
|
+
action: 'Call No Answer',
|
|
94
|
+
actionFromBot: true
|
|
95
|
+
});
|
|
96
|
+
await this.updateData();
|
|
97
|
+
return this.exitStep('no answer', errorCall);
|
|
98
|
+
default:
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
101
|
+
await this.transcript(errorCall, {
|
|
102
|
+
action: 'Call Error',
|
|
103
|
+
actionFromBot: true
|
|
104
|
+
});
|
|
105
|
+
return this.throwError({
|
|
106
|
+
name: error?.name ?? 'VoiceError',
|
|
107
|
+
message: `${String(error?.date)}: ${errorStatus}`
|
|
108
|
+
});
|
|
109
|
+
}
|
|
58
110
|
async onCall(event, call) {
|
|
59
111
|
const { endUserNumber,
|
|
60
112
|
// isAMD
|
|
@@ -99,7 +151,7 @@ class MeetOps extends voice_1.default {
|
|
|
99
151
|
name: 'meet-ops',
|
|
100
152
|
params: {
|
|
101
153
|
meetOps: {
|
|
102
|
-
dtmfPin: '
|
|
154
|
+
dtmfPin: '798 365 010 1210#'.replace(/ /g, ''),
|
|
103
155
|
durationMs: 10 * 60 * 1000,
|
|
104
156
|
idleTimeoutMs: 60 * 1000,
|
|
105
157
|
},
|
|
@@ -115,6 +167,7 @@ class MeetOps extends voice_1.default {
|
|
|
115
167
|
})
|
|
116
168
|
} */
|
|
117
169
|
await this.sendCommands(newCall, commands);
|
|
170
|
+
return this.exitStep('success');
|
|
118
171
|
}
|
|
119
172
|
async originate(call) {
|
|
120
173
|
const { id: callId } = call;
|
|
@@ -123,7 +176,11 @@ class MeetOps extends voice_1.default {
|
|
|
123
176
|
// tts,
|
|
124
177
|
from: botNumber, endUserNumber: dianInNumber, sipHost, sipUser, sipPassword, timeout, headers, enableSpoofCallerId, spoofCallerId,
|
|
125
178
|
// isAMD,
|
|
126
|
-
otherCallRef, otherCallRefThread, meetOps
|
|
179
|
+
otherCallRef, otherCallRefThread, meetOps = {
|
|
180
|
+
dtmfPin: '798 365 010 1210#'.replace(/ /g, ''),
|
|
181
|
+
durationMs: 10 * 60 * 1000,
|
|
182
|
+
idleTimeoutMs: 60 * 1000,
|
|
183
|
+
},
|
|
127
184
|
// handleCancel
|
|
128
185
|
} = this.data;
|
|
129
186
|
const customHeadersEntities = headers?.map(({ name, value }) => [name, `${value}`]) || [];
|
package/dst/Send DTMF.js
CHANGED