@onereach/step-voice 1.2202.8 → 1.2202.9
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/Cancel.d.ts +1 -1
- package/dst/Cancel.js +2 -2
- package/dst/Choice.d.ts +1 -1
- package/dst/Choice.js +2 -2
- package/dst/Conference Dial.d.ts +1 -1
- package/dst/Conference Dial.js +2 -2
- package/dst/Global Command.d.ts +1 -1
- package/dst/Global Command.js +2 -2
- package/dst/Keypad Input.d.ts +1 -1
- package/dst/Keypad Input.js +2 -2
- package/dst/Pickup.d.ts +1 -1
- package/dst/Pickup.js +2 -2
- package/dst/Transfer.d.ts +4 -0
- package/dst/Transfer.js +81 -0
- package/dst/Voice Recording.d.ts +1 -1
- package/dst/Voice Recording.js +2 -2
- package/dst/voice.js +9 -3
- package/package.json +1 -1
package/dst/Cancel.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export default class
|
|
1
|
+
export default class VoiceCancel extends VoiceStep<any, any> {
|
|
2
2
|
constructor(thread: import("@onereach/flow-sdk/dst/types").IThread, stepData: import("@onereach/flow-sdk/dst/types").IStepData<any>);
|
|
3
3
|
}
|
|
4
4
|
import VoiceStep from "./voice";
|
package/dst/Cancel.js
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
const voice_1 = (0, tslib_1.__importDefault)(require("./voice"));
|
|
5
|
-
class
|
|
5
|
+
class VoiceCancel extends voice_1.default {
|
|
6
6
|
async runStep() {
|
|
7
7
|
const channel = await this.fetchData();
|
|
8
8
|
await this.sendCommands(channel, [{ name: 'cancel' }]);
|
|
9
9
|
return this.exitStep('next');
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
|
-
exports.default =
|
|
12
|
+
exports.default = VoiceCancel;
|
package/dst/Choice.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export default class
|
|
1
|
+
export default class Choice extends VoiceStep<any, any> {
|
|
2
2
|
constructor(thread: import("@onereach/flow-sdk/dst/types").IThread, stepData: import("@onereach/flow-sdk/dst/types").IStepData<any>);
|
|
3
3
|
}
|
|
4
4
|
import VoiceStep from "./voice";
|
package/dst/Choice.js
CHANGED
|
@@ -65,7 +65,7 @@ const isRepromptTrigger = (recogResult, promptsTriggers) => {
|
|
|
65
65
|
});
|
|
66
66
|
return !_.isEmpty(phrases.filter((e) => triggers.indexOf(e) !== -1));
|
|
67
67
|
};
|
|
68
|
-
class
|
|
68
|
+
class Choice extends voice_1.default {
|
|
69
69
|
async runStep() {
|
|
70
70
|
const channel = await this.fetchData();
|
|
71
71
|
const { textType, asr, tts, sensitiveData, noReplyDelay, usePromptsTriggers } = this.data;
|
|
@@ -255,5 +255,5 @@ class VoiceChoice extends voice_1.default {
|
|
|
255
255
|
});
|
|
256
256
|
}
|
|
257
257
|
}
|
|
258
|
-
exports.default =
|
|
258
|
+
exports.default = Choice;
|
|
259
259
|
// --------------------------------------------------------------------
|
package/dst/Conference Dial.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export default class
|
|
1
|
+
export default class ConferenceDial extends VoiceStep<any, any> {
|
|
2
2
|
constructor(thread: import("@onereach/flow-sdk/dst/types").IThread, stepData: import("@onereach/flow-sdk/dst/types").IStepData<any>);
|
|
3
3
|
}
|
|
4
4
|
import VoiceStep from "./voice";
|
package/dst/Conference Dial.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
const voice_1 = (0, tslib_1.__importDefault)(require("./voice"));
|
|
5
5
|
const _ = require('lodash');
|
|
6
|
-
class
|
|
6
|
+
class ConferenceDial extends voice_1.default {
|
|
7
7
|
async runStep() {
|
|
8
8
|
const channel = await this.fetchData();
|
|
9
9
|
this.triggers
|
|
@@ -42,4 +42,4 @@ class KickFromConference extends voice_1.default {
|
|
|
42
42
|
});
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
|
-
exports.default =
|
|
45
|
+
exports.default = ConferenceDial;
|
package/dst/Global Command.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export default class
|
|
1
|
+
export default class GlobalCommand extends VoiceStep<any, any> {
|
|
2
2
|
constructor(thread: import("@onereach/flow-sdk/dst/types").IThread, stepData: import("@onereach/flow-sdk/dst/types").IStepData<any>);
|
|
3
3
|
globThread(): Promise<void>;
|
|
4
4
|
hangup(channel: any, event: any): Promise<unknown>;
|
package/dst/Global Command.js
CHANGED
|
@@ -4,7 +4,7 @@ const tslib_1 = require("tslib");
|
|
|
4
4
|
const voice_1 = (0, tslib_1.__importDefault)(require("./voice"));
|
|
5
5
|
const { nanoid } = require('nanoid');
|
|
6
6
|
const _ = require('lodash');
|
|
7
|
-
class
|
|
7
|
+
class GlobalCommand extends voice_1.default {
|
|
8
8
|
get isGlobal() {
|
|
9
9
|
return true;
|
|
10
10
|
}
|
|
@@ -200,4 +200,4 @@ class VoiceGlobalStep extends voice_1.default {
|
|
|
200
200
|
};
|
|
201
201
|
}
|
|
202
202
|
}
|
|
203
|
-
exports.default =
|
|
203
|
+
exports.default = GlobalCommand;
|
package/dst/Keypad Input.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export default class
|
|
1
|
+
export default class KeypadInput extends VoiceStep<any, any> {
|
|
2
2
|
constructor(thread: import("@onereach/flow-sdk/dst/types").IThread, stepData: import("@onereach/flow-sdk/dst/types").IStepData<any>);
|
|
3
3
|
}
|
|
4
4
|
import VoiceStep from "./voice";
|
package/dst/Keypad Input.js
CHANGED
|
@@ -23,7 +23,7 @@ const validateInput = ({ input = '', type, regex, expectedLength }) => {
|
|
|
23
23
|
return true;
|
|
24
24
|
}
|
|
25
25
|
};
|
|
26
|
-
class
|
|
26
|
+
class KeypadInput extends voice_1.default {
|
|
27
27
|
async runStep() {
|
|
28
28
|
const channel = await this.fetchData();
|
|
29
29
|
const { interTimeout, asr, tts, noReplyDelay, textType, keypadBargeIn, endInput, terminationKey, endUserInputValidationOther, expectedNumberOfDigits, regExToValidate, mfVersion } = this.data;
|
|
@@ -172,4 +172,4 @@ class VoiceKeypadInput extends voice_1.default {
|
|
|
172
172
|
});
|
|
173
173
|
}
|
|
174
174
|
}
|
|
175
|
-
exports.default =
|
|
175
|
+
exports.default = KeypadInput;
|
package/dst/Pickup.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export default class
|
|
1
|
+
export default class Pickup extends VoiceStep<any, any> {
|
|
2
2
|
constructor(thread: import("@onereach/flow-sdk/dst/types").IThread, stepData: import("@onereach/flow-sdk/dst/types").IStepData<any>);
|
|
3
3
|
}
|
|
4
4
|
import VoiceStep from "./voice";
|
package/dst/Pickup.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
const voice_1 = (0, tslib_1.__importDefault)(require("./voice"));
|
|
5
|
-
class
|
|
5
|
+
class Pickup extends voice_1.default {
|
|
6
6
|
async runStep() {
|
|
7
7
|
const channel = await this.fetchData();
|
|
8
8
|
channel.asr = this.data.asr.getSettings(channel.asr);
|
|
@@ -10,4 +10,4 @@ class VoiceChoice extends voice_1.default {
|
|
|
10
10
|
return this.exitStep('next');
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
|
-
exports.default =
|
|
13
|
+
exports.default = Pickup;
|
package/dst/Transfer.js
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const voice_1 = (0, tslib_1.__importDefault)(require("./voice"));
|
|
5
|
+
class Transfer extends voice_1.default {
|
|
6
|
+
async runStep() {
|
|
7
|
+
const channel = await this.fetchData();
|
|
8
|
+
return this.triggers
|
|
9
|
+
.once(`in/voice/${channel.id}/event`, async (event) => {
|
|
10
|
+
switch (event.params.type) {
|
|
11
|
+
case 'bridge': {
|
|
12
|
+
await this.transcript(channel, {
|
|
13
|
+
action: 'Transfer Answered',
|
|
14
|
+
actionFromBot: true,
|
|
15
|
+
reportingSettingsKey: 'transcriptAnswered'
|
|
16
|
+
});
|
|
17
|
+
// TODO
|
|
18
|
+
// this.set(`__transferAnswered_${this.currentStepId}`, true)
|
|
19
|
+
// this.set('__sessionEndedBy', 'Transfer')
|
|
20
|
+
// Maximum transfer duration
|
|
21
|
+
this.triggers.timeout(60 * 60 * 1000, () => { });
|
|
22
|
+
return this.exitFlow();
|
|
23
|
+
}
|
|
24
|
+
case 'bridge/ended': {
|
|
25
|
+
if (event.params.error === 'NORMAL_CLEARING') {
|
|
26
|
+
await this.transcript(channel, {
|
|
27
|
+
action: 'Transfer Ended - Answered',
|
|
28
|
+
actionFromBot: true,
|
|
29
|
+
reportingSettingsKey: 'transcriptEndedAnswered'
|
|
30
|
+
});
|
|
31
|
+
return this.exitStep('success');
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
await this.transcript(channel, {
|
|
35
|
+
action: 'Transfer Ended - Not Answered',
|
|
36
|
+
actionFromBot: true,
|
|
37
|
+
reportingSettingsKey: 'transcriptEndedNotAnswered'
|
|
38
|
+
});
|
|
39
|
+
return this.exitStep('no answer');
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
case 'hangup': {
|
|
43
|
+
await this.handleHangup(channel);
|
|
44
|
+
return this.end();
|
|
45
|
+
}
|
|
46
|
+
case 'error':
|
|
47
|
+
return this.throwError(event.params.error);
|
|
48
|
+
}
|
|
49
|
+
return this.exitFlow();
|
|
50
|
+
})
|
|
51
|
+
.otherwise(async () => {
|
|
52
|
+
const { phoneNumber, sessionTimeout, destination, sipHeaders = [], refer } = this.data;
|
|
53
|
+
const destinationIsSip = (/^sip:/i).test(destination);
|
|
54
|
+
const destinationIsUser = (/^user:/i).test(destination);
|
|
55
|
+
const callerID = phoneNumber;
|
|
56
|
+
const timeout = Number(sessionTimeout);
|
|
57
|
+
const headers = Object.fromEntries(sipHeaders.map(({ name, value }) => [name, value]));
|
|
58
|
+
const command = {
|
|
59
|
+
name: destinationIsSip ? (refer ? 'refer' : 'bridge_sip') : (destinationIsUser ? 'bridge_user' : 'bridge'),
|
|
60
|
+
params: {
|
|
61
|
+
transferFrom: callerID,
|
|
62
|
+
transferTo: destination,
|
|
63
|
+
headers,
|
|
64
|
+
timeout
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
await this.sendCommands(channel, [command]);
|
|
68
|
+
await this.transcript(channel, {
|
|
69
|
+
action: 'Transfer Start',
|
|
70
|
+
actionFromBot: true,
|
|
71
|
+
reportingSettingsKey: 'transcript'
|
|
72
|
+
});
|
|
73
|
+
if (destinationIsSip && refer) {
|
|
74
|
+
// this.set('__sessionEndedBy', 'Transfer')
|
|
75
|
+
return this.exitStep('success');
|
|
76
|
+
}
|
|
77
|
+
return this.exitFlow();
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
exports.default = Transfer;
|
package/dst/Voice Recording.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export default class
|
|
1
|
+
export default class Recording extends VoiceStep<any, any> {
|
|
2
2
|
constructor(thread: import("@onereach/flow-sdk/dst/types").IThread, stepData: import("@onereach/flow-sdk/dst/types").IStepData<any>);
|
|
3
3
|
}
|
|
4
4
|
import VoiceStep from "./voice";
|
package/dst/Voice Recording.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
const voice_1 = (0, tslib_1.__importDefault)(require("./voice"));
|
|
5
5
|
const _ = require('lodash');
|
|
6
|
-
class
|
|
6
|
+
class Recording extends voice_1.default {
|
|
7
7
|
async runStep() {
|
|
8
8
|
const channel = await this.fetchData();
|
|
9
9
|
const { tts, sensitiveData, textType } = this.data;
|
|
@@ -79,4 +79,4 @@ class RequestVoiceRecordingInput extends voice_1.default {
|
|
|
79
79
|
});
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
|
-
exports.default =
|
|
82
|
+
exports.default = Recording;
|
package/dst/voice.js
CHANGED
|
@@ -49,13 +49,19 @@ class VoiceStep extends step_1.default {
|
|
|
49
49
|
.value();
|
|
50
50
|
}
|
|
51
51
|
async transcript(channel, data = {}) {
|
|
52
|
-
const { previousTranscriptId = channel.lastTranscriptId, action, keyPress, message, voiceProcessResult, reportingSettingsKey, sections, reprompt, recording, conferenceId, actionFromBot } = data;
|
|
52
|
+
const { previousTranscriptId = channel.lastTranscriptId, action, keyPress, message, voiceProcessResult, reportingSettingsKey, sections, reprompt, recording, conferenceId, actionFromBot = false } = data;
|
|
53
53
|
const eventId = (0, uuid_1.v4)();
|
|
54
|
+
const fromIdentifier = actionFromBot ? channel.botNumber : channel.endUserNumber;
|
|
55
|
+
const toIdentifier = actionFromBot ? channel.endUserNumber : channel.botNumber;
|
|
56
|
+
const fromIsSip = (/^sip:/i).test(fromIdentifier);
|
|
57
|
+
const toIsSip = (/^sip:/i).test(toIdentifier);
|
|
54
58
|
const reportingObject = {
|
|
55
59
|
botIdentifier: channel.botNumber,
|
|
56
60
|
channel: 'Phone',
|
|
57
|
-
fromIdentifier
|
|
58
|
-
|
|
61
|
+
fromIdentifier,
|
|
62
|
+
fromIdentifierType: fromIsSip ? 'SIP' : undefined,
|
|
63
|
+
toIdentifier,
|
|
64
|
+
toIdentifierType: toIsSip ? 'SIP' : undefined,
|
|
59
65
|
reportingSettingsKey,
|
|
60
66
|
conversationId: channel.id,
|
|
61
67
|
previousTranscriptId,
|