Skip to content

Commit

Permalink
feat(voice): adding advanced machine detection (#835)
Browse files Browse the repository at this point in the history
  • Loading branch information
manchuck authored Jun 26, 2023
1 parent 858b41e commit 1739320
Show file tree
Hide file tree
Showing 11 changed files with 55 additions and 11 deletions.
17 changes: 8 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions packages/voice/__tests__/__dataSets__/create.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {
AdvancedMachineDetectionMode,
CallDirection,
CallStatus,
HttpMethod,
Expand Down Expand Up @@ -41,6 +42,11 @@ export default [
event_url: ['example.com'],
event_method: HttpMethod.GET,
machine_detection: MachineDetectionBehavior.CONTINUE,
advanced_machine_detection: {
behavior: MachineDetectionBehavior.HANGUP,
mode: AdvancedMachineDetectionMode.DETECT,
beep_timeout: 42,
},
length_timer: 84,
ringing_timer: 126,
},
Expand Down Expand Up @@ -80,6 +86,11 @@ export default [
eventUrl: ['example.com'],
eventMethod: HttpMethod.GET,
machineDetection: MachineDetectionBehavior.CONTINUE,
advancedMachineDetection: {
behavior: MachineDetectionBehavior.HANGUP,
mode: AdvancedMachineDetectionMode.DETECT,
beepTimeout: 42,
},
lengthTimer: 84,
ringingTimer: 126,
} as CallWithNCCO,
Expand Down Expand Up @@ -117,6 +128,11 @@ export default [
event_url: ['example.com'],
event_method: HttpMethod.GET,
machine_detection: MachineDetectionBehavior.CONTINUE,
advanced_machine_detection: {
behavior: MachineDetectionBehavior.HANGUP,
mode: AdvancedMachineDetectionMode.DETECT,
beep_timeout: 42,
},
length_timer: 84,
ringing_timer: 126,
},
Expand Down Expand Up @@ -152,6 +168,11 @@ export default [
eventUrl: ['example.com'],
eventMethod: HttpMethod.GET,
machineDetection: MachineDetectionBehavior.CONTINUE,
advancedMachineDetection: {
behavior: MachineDetectionBehavior.HANGUP,
mode: AdvancedMachineDetectionMode.DETECT,
beepTimeout: 42,
},
lengthTimer: 84,
ringingTimer: 126,
} as CallWithAnswerURL,
Expand Down
File renamed without changes.
4 changes: 4 additions & 0 deletions packages/voice/lib/enums/AdvancedMachineDetectionMode.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export enum AdvancedMachineDetectionMode {
DETECT = 'detect',
DETECTBEEP = 'detect_beep',
}
1 change: 1 addition & 0 deletions packages/voice/lib/enums/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './AdvancedMachineDetectionMode';
export * from './CallDirection';
export * from './CallStatus';
export * from './HttpMethod';
Expand Down
1 change: 0 additions & 1 deletion packages/voice/lib/interfaces/OutboundCall.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { CallEndpoint } from '../types/Endpoint/CallEndpoint';
import { PhoneEndpointObject } from './Endpoint/PhoneEndpointObject';

import debug from 'debug';

debug('@vonage/voice')(
Expand Down
10 changes: 10 additions & 0 deletions packages/voice/lib/types/AdvancedMachineDetection.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import {
MachineDetectionBehavior,
AdvancedMachineDetectionMode,
} from '../enums/index';

export type AdvancedMachineDetection = {
behavior: MachineDetectionBehavior;
mode: AdvancedMachineDetectionMode;
beepTimeout?: number;
};
2 changes: 2 additions & 0 deletions packages/voice/lib/types/CommonOutboundCall.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { HttpMethod, MachineDetectionBehavior } from '../enums/index';
import { CallEndpoint } from './Endpoint/index';
import { AdvancedMachineDetection } from './AdvancedMachineDetection';
import { CommonCallFields } from './CommonCallFields';

export type CommonOutboundCall = Omit<CommonCallFields, 'to'> & {
to: Array<CallEndpoint>;
machineDetection?: MachineDetectionBehavior;
advancedMachineDetection?: AdvancedMachineDetection;
lengthTimer?: number;
ringingTimer?: number;
eventUrl?: string[];
Expand Down
5 changes: 5 additions & 0 deletions packages/voice/lib/types/Requests/CreateCallRequest.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
import { OutboundCall } from '../OutboundCall';
import { AdvancedMachineDetection } from '../AdvancedMachineDetection';
import { MachineDetection } from '../../enums';

export type CreateCallRequest = {
random_from_number?: boolean;
event_url?: Array<string>;
machine_detection?: MachineDetection;
advanced_machine_detection: {
beep_timeout?: number;
} & Omit<AdvancedMachineDetection, 'beepTimeout'>;
length_timer?: number;
ringing_timer?: number;
} & Omit<
OutboundCall,
| 'randomFromNumber'
| 'eventUrl'
| 'machineDetection'
| 'advancedMachineDetection'
| 'lengthTimer'
| 'ringingTimer'
>;
1 change: 1 addition & 0 deletions packages/voice/lib/types/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './AdvancedMachineDetection';
export * from './BasicCallDetail';
export * from './CallDetail';
export * from './CallResult';
Expand Down
4 changes: 3 additions & 1 deletion packages/voice/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,12 @@
"compile": "npx tsc --build --verbose"
},
"dependencies": {
"@types/debug": "^4.1.8",
"@vonage/auth": "^1.3.0",
"@vonage/server-client": "^1.4.0",
"@vonage/vetch": "^1.3.0",
"debug": "^4.3.4"
"debug": "^4.3.4",
"ts-xor": "^1.1.0"
},
"devDependencies": {
"@types/debug": "^4.1.8",
Expand Down

0 comments on commit 1739320

Please sign in to comment.