@onereach/step-voice 7.0.45 → 7.0.46-deskphoneintegration.0

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.
@@ -0,0 +1,7 @@
1
+ import VoiceStep, { CallStartEvent, TODO } from './voice';
2
+ import { IEvent } from '@onereach/flow-sdk/dst/types/event';
3
+ export default class WaitForDeskPhoneCall extends VoiceStep<TODO, TODO, TODO> {
4
+ get conversation(): string | import("@onereach/flow-sdk/types").IMergeField;
5
+ runStep(): Promise<void>;
6
+ onCall(event: IEvent<CallStartEvent>): Promise<any>;
7
+ }
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ /* eslint-disable
3
+ @typescript-eslint/strict-boolean-expressions,
4
+ @typescript-eslint/explicit-function-return-type,
5
+ @typescript-eslint/no-misused-promises
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ const tslib_1 = require("tslib");
9
+ const voice_1 = tslib_1.__importDefault(require("./voice"));
10
+ const defaultSessionTimeout = 5 * 60 * 1000;
11
+ class WaitForDeskPhoneCall extends voice_1.default {
12
+ get conversation() {
13
+ if (this.step.dataOut == null)
14
+ throw new Error('missing step.dataOut');
15
+ return this.step.dataOut;
16
+ }
17
+ async runStep() {
18
+ const sipUsername = String(this.data.sipUsername ?? '').trim();
19
+ if (sipUsername) {
20
+ this.triggers.on(`in/voice/deskphone/${sipUsername}/call`, this.onCall);
21
+ }
22
+ }
23
+ async onCall(event) {
24
+ const { asr, tts, endOfInputTimeout } = this.data;
25
+ const dialedNumber = event.params.channel.to;
26
+ const fromUser = event.params.fromUser;
27
+ const call = {
28
+ headers: event.params.headers,
29
+ // @ts-expect-error
30
+ botNumber: event.params.channel.to ?? 'unknown',
31
+ // For a breakout the "caller" is the desk phone, not an owned bot number.
32
+ // @ts-expect-error
33
+ endUserNumber: fromUser ?? event.params.channel?.from ?? 'unknown',
34
+ ...event.params.channel,
35
+ asr: asr.getSettings(),
36
+ tts: tts.getVoice()
37
+ };
38
+ delete call.from;
39
+ delete call.to;
40
+ call.dialedNumber = dialedNumber;
41
+ call.fromUser = fromUser;
42
+ const presetTime = (Number(endOfInputTimeout) || 0) * 60 * 1000;
43
+ const { sessionId: previousSessionId = '', beginningSessionId = '', } = event?.reporting ?? {};
44
+ await this.session.start({
45
+ timeout: presetTime || defaultSessionTimeout,
46
+ reporting: {
47
+ settingsKey: 'session',
48
+ startedBy: 'Visitor',
49
+ sessionType: 'Phone',
50
+ previousSessionId,
51
+ beginningSessionId
52
+ },
53
+ reportingSessions: [{
54
+ previousSessionId,
55
+ beginningSessionId
56
+ }]
57
+ });
58
+ await this.startConversation(call);
59
+ await this.transcript(call, {
60
+ action: 'Call Start',
61
+ reportingSettingsKey: 'transcript',
62
+ actionFromBot: false
63
+ });
64
+ return this.exitStep('trigger');
65
+ }
66
+ }
67
+ exports.default = WaitForDeskPhoneCall;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onereach/step-voice",
3
- "version": "7.0.45",
3
+ "version": "7.0.46-deskphoneintegration.0",
4
4
  "author": "Roman Zolotarov <roman.zolotarov@onereach.com>",
5
5
  "contributors": [
6
6
  "Roman Zolotarov",