Skip to content

Commit

Permalink
Merge pull request Cognigy#456 from VIER-CognitiveVoice/feature/VIER-…
Browse files Browse the repository at this point in the history
…CVG-extension

Update to VIER CVG Extension 4.6.0
  • Loading branch information
alexteusz committed Sep 6, 2023
2 parents 78c8929 + 4d8abaa commit 511bb40
Show file tree
Hide file tree
Showing 12 changed files with 289 additions and 97 deletions.
2 changes: 1 addition & 1 deletion extensions/vier-cognitive-voice-gateway/package.json
@@ -1,7 +1,7 @@
{
"name": "vier-voice",
"description": "Enable phone bots with VIER Cognitive Voice Gateway",
"version": "4.5.0",
"version": "4.6.0",
"main": "build/module.js",
"author": "VIER GmbH",
"license": "MIT",
Expand Down
17 changes: 14 additions & 3 deletions extensions/vier-cognitive-voice-gateway/source-translation.json
Expand Up @@ -7,8 +7,6 @@
"forward": {
"nodeLabel": "Forward Call",
"nodeSummary": "Forward the call to a different destination",
"inputDestinationNumberLabel": "Destination Number",
"inputDestinationNumberDescription": "The phone number to forward to (+E.164 format, e.g. +49721480848680)",
"sectionGeneralLabel": "General Settings",
"sectionCallLabel": "Call Settings",
"sectionAdditionalDataLabel": "Data",
Expand All @@ -22,6 +20,10 @@
"inputExtensionLengthLabel": "Extension Length",
"inputExtensionLengthDescription": "The range of extensions to choose a number from"
},
"refer": {
"nodeLabel": "Refer Call",
"nodeSummary": "Transfer the call to a different destination using SIP REFER"
},
"multipleChoicePrompt": {
"nodeLabel": "Get Multiple Choice Answer from Caller",
"nodeSummary": "Say something to the call with a multiple choice prompt",
Expand Down Expand Up @@ -84,6 +86,8 @@
"inputCallerIdDescription": "The phone number displayed to the callee. (This is a best-effort option, correct display can not be guaranteed)",
"inputCustomSipHeadersLabel": "Custom SIP Headers",
"inputCustomSipHeadersDescription": "An object where each property is the name of a header, and the value is a list of strings. All header names must begin with X-.",
"inputUserToUserLabel": "User-To-User Information",
"inputUserToUserDescription": "A list of opaque strings that are send as User-To-User SIP headers.",
"inputRingTimeoutLabel": "Ring Timeout (s)",
"inputRingTimeoutDescription": "The maximum time (in seconds) the call will be ringing before the attempt will be cancelled",
"inputAcceptAnsweringMachinesLabel": "Accept Answering Machines",
Expand All @@ -96,10 +100,13 @@
"inputExperimentalEnableRingingToneDescription": "Enables the playback of a ringing tone while the call is pending. This option will change in the future.",
"inputWhisperingTextLabel": "Whisperred Text to the transfered party",
"inputWhisperingTextDescription": "The text played out to the person the call is transfered to before both call parties will be joined",
"inputDestinationLabel": "Destination Number",
"inputDestinationDescription": "The phone number to forward to (+E.164 format, e.g. +49721480848680)",
"childSuccessLabel": "On Success",
"childFailureLabel": "On Failure",
"childTerminationLabel": "On Termination",
"childDefaultLabel": "Default"
"childDefaultLabel": "Default",
"sectionSipLabel": "SIP"
},
"bargeIn": {
"input": {
Expand Down Expand Up @@ -148,6 +155,10 @@
"nodeLabel": "Check Outbound Result",
"nodeSummary": "Check the Result of the Outbound Call"
},
"referService": {
"nodeLabel": "Check Refer Result",
"nodeSummary": "Check the result of the call refer"
},
"timer": {
"nodeLabel": "Inactivity Timeout",
"nodeSummary": "Sets the Inactivity Timeout in (s)",
Expand Down
24 changes: 24 additions & 0 deletions extensions/vier-cognitive-voice-gateway/src/common/shared.ts
@@ -1,4 +1,6 @@
import {
INodeAppearance,
INodeConstraints,
INodeField,
INodeFieldTranslations,
} from '@cognigy/extension-tools/build/interfaces/descriptor';
Expand Down Expand Up @@ -111,3 +113,25 @@ export const endFlowField: INodeField = {
required: true,
},
};

export const commonChildNodeFields: {
appearance: INodeAppearance,
constraints?: INodeConstraints
} = {
constraints: {
editable: false,
deletable: false,
creatable: false,
movable: false,
placement: {
predecessor: {
whitelist: [],
},
},
},
appearance: {
color: '#61d188',
textColor: 'white',
variant: 'mini',
},
}
23 changes: 16 additions & 7 deletions extensions/vier-cognitive-voice-gateway/src/common/transferCall.ts
Expand Up @@ -11,6 +11,7 @@ import {

export interface TransferCallInputs extends EndFlowInputs {
callerId?: string;
userToUserInformation?: Array<string>
customSipHeaders?: object;
ringTimeout?: number;
acceptAnsweringMachines?: boolean;
Expand All @@ -29,7 +30,14 @@ const callerIdField: INodeField = {
},
};

const customSipHeadersField: INodeField = {
export const userToUserField: INodeField = {
type: 'textArray',
key: 'userToUserInformation',
label: t.shared.inputUserToUserLabel,
description: t.shared.inputUserToUserDescription,
};

export const customSipHeadersField: INodeField = {
type: 'json',
key: 'customSipHeaders',
label: t.shared.inputCustomSipHeadersLabel,
Expand Down Expand Up @@ -82,6 +90,7 @@ const whisperingTextField: INodeField = {
export const transferCallFields: Array<INodeField> = [
callerIdField,
customSipHeadersField,
userToUserField,
ringTimeoutField,
acceptAnsweringMachinesField,
dataField,
Expand All @@ -97,10 +106,10 @@ const callSection: INodeSection = {
defaultCollapsed: true,
};

const sipHeadersSection: INodeSection = {
key: 'sipHeaders',
fields: [customSipHeadersField.key],
label: t.shared.inputCustomSipHeadersLabel,
const sipSection: INodeSection = {
key: 'sip',
fields: [userToUserField.key, customSipHeadersField.key],
label: t.shared.sectionSipLabel,
defaultCollapsed: true,
};

Expand All @@ -120,7 +129,7 @@ const additionalSettingsSection: INodeSection = {

export const transferCallSections: Array<INodeSection> = [
callSection,
sipHeadersSection,
sipSection,
additionalDataSection,
additionalSettingsSection,
];
Expand All @@ -131,7 +140,7 @@ export const transferCallForm: Array<INodeFieldAndSectionFormElement> = [
type: 'section',
},
{
key: sipHeadersSection.key,
key: sipSection.key,
type: 'section',
},
{
Expand Down
19 changes: 19 additions & 0 deletions extensions/vier-cognitive-voice-gateway/src/helpers/util.ts
Expand Up @@ -103,6 +103,25 @@ export function normalizeSipHeaders(headersObject: object | undefined): CustomSi
return headers;
}

export function normalizeUserToUserInformation(userToUserInformation: Array<string> | undefined): Array<string> | undefined {
if (!Array.isArray(userToUserInformation)) {
return undefined;
}

const information: Array<string> = []
for (const line of userToUserInformation) {
if (line === undefined || line === null || line === '') {
continue;
}
information.push(`${line}`)
}
if (information.length === 0) {
return undefined;
}

return information;
}

export const DEFAULT_NUMBER_VALUE = 'none';

function toNumberOrUndefined(numeric: number | string | undefined | null): number | undefined {
Expand Down
14 changes: 13 additions & 1 deletion extensions/vier-cognitive-voice-gateway/src/module.ts
Expand Up @@ -20,6 +20,13 @@ import {
onOutboundSuccess,
onOutboundTermination,
} from './nodes/checkOutboundResult';
import {
checkReferResultNode,
onReferDefault,
onReferFailure,
onReferSuccess
} from './nodes/checkReferResult';
import { referCallNode } from './nodes/referCall';

export default createExtension({
nodes: [
Expand All @@ -32,18 +39,23 @@ export default createExtension({
sendDataNode,
forwardCallNode,
bridgeCallNode,
referCallNode,
terminateCallNode,
speakNode,
checkOutboundResultNode,
onOutboundSuccess, // child
onOutboundFailure, // child
onOutboundTermination, // child
onOutboundDefault, // child
checkReferResultNode,
onReferSuccess, // child
onReferFailure, // child
onReferDefault, // child
setSpeechtoTextServiceNode,
inactivityTimerNode,
aggregateInputNode,
],
options: {
label: 'VIER Voice',
},
});
});
Expand Up @@ -9,6 +9,7 @@ import {
normalizeData,
normalizeSipHeaders,
normalizeText,
normalizeUserToUserInformation,
} from '../helpers/util';
import t from '../translations';
import {
Expand Down Expand Up @@ -92,6 +93,7 @@ export const bridgeCallNode = createNodeDescriptor({
extensionLength: config.extensionLength,
callerId: normalizeText(config.callerId),
customSipHeaders: normalizeSipHeaders(config.customSipHeaders),
userToUserInformation: normalizeUserToUserInformation(config.userToUserInformation),
ringTimeout: convertDurationFromSecondsToMillis(config.ringTimeout),
acceptAnsweringMachines: config.acceptAnsweringMachines,
data: normalizeData(api, config.data),
Expand Down
Expand Up @@ -3,6 +3,7 @@ import {
INodeFunctionBaseParams,
} from '@cognigy/extension-tools/build';
import t from '../translations';
import { commonChildNodeFields } from '../common/shared';

export const checkOutboundResultNode = createNodeDescriptor({
type: 'outboundService',
Expand Down Expand Up @@ -35,19 +36,24 @@ export const checkOutboundResultNode = createNodeDescriptor({
return child;
}

const onFailureChild = childByType('onOutboundFailure');
const onSuccessChild = childByType('onOutboundSuccess');
const onFailureChild = childByType('onOutboundFailure');
const onTerminateChild = childByType('onOutboundTermination');
const onDefaultChild = childByType('onOutboundDefault');

if (cognigy.input.data.status === 'outbound-success') {
api.setNextNode(onSuccessChild.id);
} else if (cognigy.input.data.status === 'outbound-failure') {
api.setNextNode(onFailureChild.id);
} else if (cognigy.input.data.status === 'termination') {
api.setNextNode(onTerminateChild.id);
} else {
api.setNextNode(onDefaultChild.id);
switch (cognigy.input.data.status) {
case 'outbound-success':
api.setNextNode(onSuccessChild.id);
break;
case 'outbound-failure':
api.setNextNode(onFailureChild.id);
break;
case 'termination':
api.setNextNode(onTerminateChild.id);
break;
default:
api.setNextNode(onDefaultChild.id);
break;
}
},
});
Expand All @@ -56,86 +62,26 @@ export const onOutboundSuccess = createNodeDescriptor({
type: 'onOutboundSuccess',
parentType: 'outbound',
defaultLabel: t.shared.childSuccessLabel,
constraints: {
editable: false,
deletable: false,
creatable: false,
movable: false,
placement: {
predecessor: {
whitelist: [],
},
},
},
appearance: {
color: '#61d188',
textColor: 'white',
variant: 'mini',
},
...commonChildNodeFields,
});

export const onOutboundFailure = createNodeDescriptor({
type: 'onOutboundFailure',
parentType: 'outbound',
defaultLabel: t.shared.childFailureLabel,
constraints: {
editable: false,
deletable: false,
creatable: false,
movable: false,
placement: {
predecessor: {
whitelist: [],
},
},
},
appearance: {
color: '#61d188',
textColor: 'white',
variant: 'mini',
},
...commonChildNodeFields,
});

export const onOutboundTermination = createNodeDescriptor({
type: 'onOutboundTermination',
parentType: 'outbound',
defaultLabel: t.shared.childTerminationLabel,
constraints: {
editable: false,
deletable: false,
creatable: false,
movable: false,
placement: {
predecessor: {
whitelist: [],
},
},
},
appearance: {
color: '#61d188',
textColor: 'white',
variant: 'mini',
},
...commonChildNodeFields,
});

export const onOutboundDefault = createNodeDescriptor({
type: 'onOutboundDefault',
parentType: 'outbound',
defaultLabel: t.shared.childDefaultLabel,
constraints: {
editable: false,
deletable: true,
creatable: false,
movable: false,
placement: {
predecessor: {
whitelist: [],
},
},
},
appearance: {
color: '#61d188',
textColor: 'white',
variant: 'mini',
},
...commonChildNodeFields,
});

0 comments on commit 511bb40

Please sign in to comment.