@onereach/step-voice 6.0.8 → 6.0.10
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 +27 -14
- package/dst/voice.d.ts +6 -1
- package/package.json +1 -1
package/dst/Initiate Call.js
CHANGED
|
@@ -47,7 +47,7 @@ class InitiateCall extends voice_1.default {
|
|
|
47
47
|
this.exitStep('cancel');
|
|
48
48
|
}
|
|
49
49
|
async waitForCall() {
|
|
50
|
-
const { asr, tts, from: botNumber, endUserNumber, sipHost, sipUser, sipPassword, timeout, headers, enableSpoofCallerId, spoofCallerId, isAMD, otherCallRef, otherCallRefThread } = this.data;
|
|
50
|
+
const { asr, tts, from: botNumber, endUserNumber, sipHost, sipUser, sipPassword, timeout, headers, enableSpoofCallerId, spoofCallerId, isAMD, otherCallRef, otherCallRefThread, handleCancel } = this.data;
|
|
51
51
|
const call = await this.fetchData();
|
|
52
52
|
this.triggers.once(`in/voice/${call.id}/event`, async (event) => {
|
|
53
53
|
switch (event.params.type) {
|
|
@@ -106,34 +106,47 @@ class InitiateCall extends voice_1.default {
|
|
|
106
106
|
}
|
|
107
107
|
case 'hangup': {
|
|
108
108
|
await this.handleHangup(call);
|
|
109
|
-
|
|
110
|
-
|
|
109
|
+
if (handleCancel && event.params.error?.name === 'CancelError') {
|
|
110
|
+
return this.exitStep('cancel');
|
|
111
|
+
}
|
|
112
|
+
return this.throwError(event.params.error ?? {
|
|
113
|
+
name: 'HangupError',
|
|
114
|
+
message: 'unpexpected hangup during init call'
|
|
115
|
+
});
|
|
111
116
|
}
|
|
112
117
|
case 'error': {
|
|
113
|
-
const error =
|
|
118
|
+
const error = event.params.error;
|
|
119
|
+
const errorStatus = error?.originateStatus ?? 'UNKNOWN';
|
|
114
120
|
const errorCall = {
|
|
115
121
|
botNumber,
|
|
116
122
|
endUserNumber
|
|
117
123
|
};
|
|
118
|
-
switch (
|
|
124
|
+
switch (errorStatus) {
|
|
119
125
|
case 'USER_BUSY':
|
|
120
|
-
await this.transcript(errorCall, {
|
|
126
|
+
await this.transcript(errorCall, {
|
|
127
|
+
action: 'Call Busy',
|
|
128
|
+
actionFromBot: true
|
|
129
|
+
});
|
|
121
130
|
await this.updateData();
|
|
122
131
|
return this.exitStep('busy', errorCall);
|
|
123
132
|
case 'NO_ANSWER':
|
|
124
|
-
await this.transcript(errorCall, { action: 'Call No Answer' });
|
|
125
|
-
await this.updateData();
|
|
126
|
-
return this.exitStep('no answer', errorCall);
|
|
127
133
|
case 'NO_USER_RESPONSE':
|
|
128
|
-
await this.transcript(errorCall, {
|
|
134
|
+
await this.transcript(errorCall, {
|
|
135
|
+
action: 'Call No Answer',
|
|
136
|
+
actionFromBot: true
|
|
137
|
+
});
|
|
129
138
|
await this.updateData();
|
|
130
139
|
return this.exitStep('no answer', errorCall);
|
|
140
|
+
default:
|
|
141
|
+
break;
|
|
131
142
|
}
|
|
132
|
-
await this.transcript(errorCall, {
|
|
133
|
-
|
|
143
|
+
await this.transcript(errorCall, {
|
|
144
|
+
action: 'Call Error',
|
|
145
|
+
actionFromBot: true
|
|
146
|
+
});
|
|
134
147
|
return this.throwError({
|
|
135
|
-
name:
|
|
136
|
-
message: `${
|
|
148
|
+
name: error?.name ?? 'VoiceError',
|
|
149
|
+
message: `${String(error?.date)}: ${errorStatus}`
|
|
137
150
|
});
|
|
138
151
|
}
|
|
139
152
|
default:
|
package/dst/voice.d.ts
CHANGED
|
@@ -28,9 +28,14 @@ export interface IVoiceCall extends IConversationData {
|
|
|
28
28
|
export type EventType = 'hangup' | 'error' | 'cancel' | 'background' | 'avm-detected' | 'recognition' | 'digit' | 'digits' | 'conference-start' | 'conference-end' | 'playback' | 'timeout' | 'record' | 'bridge' | 'bridge/ended' | 'is_flow_ready' | 'call' | 'dtmf-sent';
|
|
29
29
|
export declare class VoiceStepError extends BasicError {
|
|
30
30
|
}
|
|
31
|
-
export type VoicerError = Error
|
|
31
|
+
export type VoicerError = Error & {
|
|
32
|
+
originateStatus?: string;
|
|
33
|
+
date?: string;
|
|
34
|
+
} | string & {
|
|
32
35
|
message?: never;
|
|
33
36
|
name?: never;
|
|
37
|
+
date?: never;
|
|
38
|
+
originateStatus?: never;
|
|
34
39
|
};
|
|
35
40
|
export interface VoiceEvent {
|
|
36
41
|
type: EventType;
|