@onereach/step-voice 7.0.2-VOIC1438.0 → 7.0.2-initaiconversation.1

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,16 @@
1
+ import VoiceStep, { VoiceEvent } from './voice';
2
+ interface INPUT {
3
+ instructions: string;
4
+ temperature: number;
5
+ modality: 'audio' | 'text';
6
+ threshold: number;
7
+ prefixPadding: number;
8
+ silenceDuration: number;
9
+ }
10
+ interface EVENT extends VoiceEvent {
11
+ exitId?: string;
12
+ }
13
+ export default class InitAIConversation extends VoiceStep<INPUT, {}, EVENT> {
14
+ runStep(): Promise<void>;
15
+ }
16
+ export {};
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const voice_1 = tslib_1.__importDefault(require("./voice"));
5
+ class InitAIConversation extends voice_1.default {
6
+ async runStep() {
7
+ const call = await this.fetchData();
8
+ const { instructions, temperature, modality, threshold, prefixPadding, silenceDuration } = this.data;
9
+ const command = {
10
+ name: 'init-ai-conversation',
11
+ params: {
12
+ instructions,
13
+ temperature,
14
+ modality,
15
+ threshold,
16
+ prefixPadding,
17
+ silenceDuration
18
+ }
19
+ };
20
+ const sensitiveData = {
21
+ muteStep: false,
22
+ muteUser: false,
23
+ muteBot: false,
24
+ };
25
+ this.triggers.local(`in/voice/${call.id}`, async (event) => {
26
+ this.log.info('Received event from voicer', event);
27
+ });
28
+ this.triggers.otherwise(async () => {
29
+ await this.pauseRecording(call, command, sensitiveData);
30
+ return this.exitFlow();
31
+ });
32
+ }
33
+ }
34
+ exports.default = InitAIConversation;
@@ -38,11 +38,9 @@ class SendDTMF extends voice_1.default {
38
38
  if (validationError != null)
39
39
  throw new Error(validationError.message);
40
40
  const command = {
41
- name: 'meet-ops',
41
+ name: 'send-dtmf',
42
42
  params: {
43
43
  dtmf,
44
- dtmfPin: dtmf,
45
- dialInNumber: '16176754444',
46
44
  tonesDuration: +tonesDuration,
47
45
  beforeDelay: +beforeDelay,
48
46
  afterDelay: +afterDelay
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onereach/step-voice",
3
- "version": "7.0.2-VOIC1438.0",
3
+ "version": "7.0.2-initaiconversation.1",
4
4
  "author": "Roman Zolotarov <roman.zolotarov@onereach.com>",
5
5
  "contributors": [
6
6
  "Roman Zolotarov",
package/dst/MeetOps.d.ts DELETED
@@ -1,29 +0,0 @@
1
- import VoiceStep, { CallStartEvent, IVoiceCall } from './voice';
2
- interface MeetOpsInput {
3
- callId?: string;
4
- sessionTimeout?: number | string;
5
- otherCallRef?: string;
6
- otherCallRefThread?: string;
7
- from: string;
8
- endUserNumber: string;
9
- sipHost?: string;
10
- sipUser?: string;
11
- sipPassword?: string;
12
- timeout?: number | string;
13
- headers?: Array<{
14
- name: string;
15
- value: string;
16
- }>;
17
- enableSpoofCallerId?: boolean;
18
- spoofCallerId?: string;
19
- isAMD?: boolean;
20
- }
21
- interface MeetOpsOutput {
22
- }
23
- export default class MeetOps extends VoiceStep<MeetOpsInput, MeetOpsOutput, CallStartEvent> {
24
- get conversation(): string | import("@onereach/flow-sdk/dst/types").IMergeField;
25
- runStep(): Promise<void>;
26
- waitForJoin(): Promise<void>;
27
- originate(call: IVoiceCall): Promise<void>;
28
- }
29
- export {};
package/dst/MeetOps.js DELETED
@@ -1,81 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- const uuid = tslib_1.__importStar(require("uuid"));
5
- const voice_1 = tslib_1.__importDefault(require("./voice"));
6
- class MeetOps extends voice_1.default {
7
- get conversation() {
8
- if (this.step.dataOut == null)
9
- throw new Error('missing step.dataOut');
10
- return this.step.dataOut;
11
- }
12
- async runStep() {
13
- const { callId = uuid.v4() } = this.data;
14
- if (!this.session.key) {
15
- await this.session.start({
16
- key: callId,
17
- timeout: 10000,
18
- reporting: {
19
- settingsKey: 'session',
20
- startedBy: 'Bot',
21
- sessionType: 'Phone'
22
- }
23
- });
24
- }
25
- const convData = { id: callId, type: 'voicer', vv: 0 };
26
- await this.startConversation(convData);
27
- this.gotoState('waitForJoin');
28
- }
29
- async waitForJoin() {
30
- const call = await this.fetchData();
31
- // this.triggers.once(`in/voice/${call.id}/event`, async (event) => {
32
- // })
33
- this.triggers.otherwise(async () => {
34
- await this.triggers.flush();
35
- await this.originate(call);
36
- });
37
- }
38
- async originate(call) {
39
- const { id: callId } = call;
40
- const {
41
- // asr,
42
- // tts,
43
- from: botNumber, endUserNumber: dianInNumber, sipHost, sipUser, sipPassword, timeout, headers, enableSpoofCallerId, spoofCallerId,
44
- // isAMD,
45
- otherCallRef, otherCallRefThread,
46
- // handleCancel
47
- } = this.data;
48
- const customHeadersEntities = headers?.map(({ name, value }) => [name, `${value}`]) || [];
49
- const customHeaders = Object.fromEntries(customHeadersEntities);
50
- const gateway = sipHost
51
- ? {
52
- host: sipHost,
53
- username: sipUser,
54
- password: sipPassword
55
- }
56
- : undefined;
57
- const spoofCallerIdConfig = {
58
- enableSpoofCallerId,
59
- spoofCallerId
60
- };
61
- const params = {
62
- id: callId,
63
- from: botNumber,
64
- to: dianInNumber,
65
- headers: customHeaders,
66
- sessionExpireTime: this.session.expireTime,
67
- spoofCallerId: spoofCallerIdConfig,
68
- version: 2,
69
- gateway,
70
- timeout,
71
- };
72
- console.log(otherCallRef, otherCallRefThread, params);
73
- // const otherThread = this.process.getSafeThread(otherCallRefThread || this.thread.id)
74
- // const otherCall: IVoiceCall | undefined = await otherThread.get(otherCallRef)
75
- // if (otherCall == null) throw new Error(`otherCall not found: ${otherCallRef}`)
76
- // await this.sendCommands(otherCall, [
77
- // { name: 'originate', params }
78
- // ])
79
- }
80
- }
81
- exports.default = MeetOps;