From a0acbdfc16fa3d1649c4a158e1a905806e8bd4c5 Mon Sep 17 00:00:00 2001 From: Jens Fischer Date: Wed, 19 Jul 2023 17:33:07 +0200 Subject: [PATCH 1/3] Add node for /call/refer --- .../source-translation.json | 10 ++ .../src/common/shared.ts | 24 +++++ .../src/module.ts | 14 ++- .../src/nodes/checkOutboundResult.ts | 92 ++++--------------- .../src/nodes/checkReferResult.ts | 72 +++++++++++++++ .../src/nodes/referCall.ts | 55 +++++++++++ .../src/translations.ts | 32 ++++++- 7 files changed, 223 insertions(+), 76 deletions(-) create mode 100644 extensions/vier-cognitive-voice-gateway/src/nodes/checkReferResult.ts create mode 100644 extensions/vier-cognitive-voice-gateway/src/nodes/referCall.ts diff --git a/extensions/vier-cognitive-voice-gateway/source-translation.json b/extensions/vier-cognitive-voice-gateway/source-translation.json index a18cf3bd..680c1358 100644 --- a/extensions/vier-cognitive-voice-gateway/source-translation.json +++ b/extensions/vier-cognitive-voice-gateway/source-translation.json @@ -22,6 +22,12 @@ "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", + "inputDestinationLabel": "Destination", + "inputDestinationDescription": "The destination to transfer to (+E.164 number or SIP URI)" + }, "multipleChoicePrompt": { "nodeLabel": "Get Multiple Choice Answer from Caller", "nodeSummary": "Say something to the call with a multiple choice prompt", @@ -148,6 +154,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)", diff --git a/extensions/vier-cognitive-voice-gateway/src/common/shared.ts b/extensions/vier-cognitive-voice-gateway/src/common/shared.ts index b68b0bff..856edb8b 100644 --- a/extensions/vier-cognitive-voice-gateway/src/common/shared.ts +++ b/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'; @@ -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', + }, +} diff --git a/extensions/vier-cognitive-voice-gateway/src/module.ts b/extensions/vier-cognitive-voice-gateway/src/module.ts index 710be79d..5b795abe 100644 --- a/extensions/vier-cognitive-voice-gateway/src/module.ts +++ b/extensions/vier-cognitive-voice-gateway/src/module.ts @@ -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: [ @@ -32,6 +39,7 @@ export default createExtension({ sendDataNode, forwardCallNode, bridgeCallNode, + referCallNode, terminateCallNode, speakNode, checkOutboundResultNode, @@ -39,6 +47,10 @@ export default createExtension({ onOutboundFailure, // child onOutboundTermination, // child onOutboundDefault, // child + checkReferResultNode, + onReferSuccess, // child + onReferFailure, // child + onReferDefault, // child setSpeechtoTextServiceNode, inactivityTimerNode, aggregateInputNode, @@ -46,4 +58,4 @@ export default createExtension({ options: { label: 'VIER Voice', }, -}); \ No newline at end of file +}); diff --git a/extensions/vier-cognitive-voice-gateway/src/nodes/checkOutboundResult.ts b/extensions/vier-cognitive-voice-gateway/src/nodes/checkOutboundResult.ts index 84ea1a8d..bc707660 100644 --- a/extensions/vier-cognitive-voice-gateway/src/nodes/checkOutboundResult.ts +++ b/extensions/vier-cognitive-voice-gateway/src/nodes/checkOutboundResult.ts @@ -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', @@ -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; } }, }); @@ -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, }); diff --git a/extensions/vier-cognitive-voice-gateway/src/nodes/checkReferResult.ts b/extensions/vier-cognitive-voice-gateway/src/nodes/checkReferResult.ts new file mode 100644 index 00000000..c96594a2 --- /dev/null +++ b/extensions/vier-cognitive-voice-gateway/src/nodes/checkReferResult.ts @@ -0,0 +1,72 @@ +import { INodeFunctionBaseParams, createNodeDescriptor } from "@cognigy/extension-tools"; +import t from '../translations'; +import { commonChildNodeFields } from "../common/shared"; + +export const checkReferResultNode = createNodeDescriptor({ + type: 'referService', + defaultLabel: t.referService.nodeLabel, + summary: t.referService.nodeSummary, + appearance: { + color: 'blue', + }, + behavior: { + entrypoint: true, + }, + tags: ['logic'], + dependencies: { + children: [ + 'onReferSuccess', + 'onReferFailure', + 'onReferDefault', + ], + }, + + function: async ({ cognigy, childConfigs }: INodeFunctionBaseParams) => { + const { api } = cognigy; + + function childByType(type: string) { + const child = childConfigs.find((child) => child.type === type); + if (!child) { + throw new Error(`Unable to find '${child}'. Seems its not attached.`); + } + return child; + } + + const onSuccessChild = childByType('onReferSuccess'); + const onFailureChild = childByType('onReferFailure'); + const onDefaultChild = childByType('onReferDefault'); + + switch (cognigy.input.data.status) { + case 'termination': + api.setNextNode(onSuccessChild.id); + break; + case 'refer-failure': + api.setNextNode(onFailureChild.id); + break; + default: + api.setNextNode(onDefaultChild.id); + break; + } + }, +}); + +export const onReferSuccess = createNodeDescriptor({ + type: 'onReferSuccess', + parentType: 'refer', + defaultLabel: t.shared.childSuccessLabel, + ...commonChildNodeFields, +}); + +export const onReferFailure = createNodeDescriptor({ + type: 'onReferFailure', + parentType: 'refer', + defaultLabel: t.shared.childFailureLabel, + ...commonChildNodeFields, +}); + +export const onReferDefault = createNodeDescriptor({ + type: 'onReferDefault', + parentType: 'refer', + defaultLabel: t.shared.childDefaultLabel, + ...commonChildNodeFields, +}); diff --git a/extensions/vier-cognitive-voice-gateway/src/nodes/referCall.ts b/extensions/vier-cognitive-voice-gateway/src/nodes/referCall.ts new file mode 100644 index 00000000..a96aca1e --- /dev/null +++ b/extensions/vier-cognitive-voice-gateway/src/nodes/referCall.ts @@ -0,0 +1,55 @@ +import { INodeFunctionBaseParams, createNodeDescriptor } from "@cognigy/extension-tools"; +import t from '../translations'; +import { normalizeText } from "../helpers/util"; +import { EndFlowInputs, endFlowField } from "../common/shared"; + +interface IReferCallInputs extends EndFlowInputs { + destination: string; +} + +export interface IReferCallParams extends INodeFunctionBaseParams { + config: IReferCallInputs; +} + +export const referCallNode = createNodeDescriptor({ + type: 'refer', + defaultLabel: t.refer.nodeLabel, + summary: t.refer.nodeSummary, + appearance: { + color: 'green', + }, + tags: ['service'], + behavior: { + entrypoint: true, + }, + fields: [ + { + type: 'cognigyText', + key: 'destination', + label: t.refer.inputDestinationLabel, + description: t.refer.inputDestinationDescription, + params: { + required: true, + placeholder: '+E.164 number or SIP URI', + }, + }, + endFlowField, + ], + preview: { + key: 'destination', + type: 'text', + }, + function: async ({ cognigy, config }: IReferCallParams) => { + const { api } = cognigy; + + const payload = { + status: 'refer', + destination: normalizeText(config.destination), + }; + + api.say('', payload); + if (config.endFlow) { + api.stopExecution(); + } + }, +}); diff --git a/extensions/vier-cognitive-voice-gateway/src/translations.ts b/extensions/vier-cognitive-voice-gateway/src/translations.ts index b4f511b3..c436e85a 100644 --- a/extensions/vier-cognitive-voice-gateway/src/translations.ts +++ b/extensions/vier-cognitive-voice-gateway/src/translations.ts @@ -4,7 +4,7 @@ export default { aggregateInput: { enableFieldDescription: { 'default': "To activate the aggregation of utterances, activate this switch.", - 'deDE': "Um die Aggregation von Aussagen einzuschalten, aktivieren Siese diesen Schalter.", + 'deDE': "Um die Aggregation von Aussagen einzuschalten, aktivieren Sie diesen Schalter.", }, enableFieldLabel: { 'default': "Enable or disable the utterance aggregation", @@ -281,6 +281,34 @@ export default { 'deDE': "Gesprächsaufzeichnung anhalten oder beenden", }, }, + refer: { + inputDestinationDescription: { + 'default': "Enter the phone number you want to forward the call to (with country code or SIP URI).", + 'deDE': "Geben Sie die Rufnummer ein, an die weitergeleitet werden soll (mit Ländervorwahl oder SIP-URI).", + }, + inputDestinationLabel: { + 'default': "Destination", + 'deDE': "Ziel", + }, + nodeLabel: { + 'default': "Forward Call (SIP REFER)", + 'deDE': "Anruf weiterleiten (SIP-REFER)", + }, + nodeSummary: { + 'default': "Forward the call to a different destination using SIP REFER", + 'deDE': "Anruf mittels SIP-REFER an ein anderes Ziel weiterleiten", + }, + }, + referService: { + nodeLabel: { + 'default': "Check Forward Result", + 'deDE': "Weiterleitungsergbnis prüfen", + }, + nodeSummary: { + 'default': "Check the result of the call forward", + 'deDE': "Ergebnis der Anrufweiterleitung prüfen", + }, + }, sendData: { inputDataDescription: { 'default': "Enter an object with arbitrary properties. Each property must have a string value.", @@ -409,7 +437,7 @@ export default { 'deDE': "Zeitüberschreitung", }, inputWhisperingTextDescription: { - 'default': "Enter the text that should be announced to the agent the call is transfered to before the call partners are connected.", + 'default': "Enter the text that should be announced to the agent the call is forwarded to before the call partners are connected.", 'deDE': "Geben Sie den Text ein, der dem:der Agent:in bei der Weiterleitung angesagt werden soll, bevor die Gesprächspartner:innen verbunden werden.", }, inputWhisperingTextLabel: { From e7d9c6e968e0d59be6ec2e141ace4b975ef6fd68 Mon Sep 17 00:00:00 2001 From: Phillip Schichtel Date: Tue, 25 Jul 2023 15:51:27 +0200 Subject: [PATCH 2/3] consolidate destination input keys --- .../source-translation.json | 8 ++--- .../src/nodes/forwardCall.ts | 4 +-- .../src/nodes/referCall.ts | 4 +-- .../src/translations.ts | 36 ++++++++----------- 4 files changed, 21 insertions(+), 31 deletions(-) diff --git a/extensions/vier-cognitive-voice-gateway/source-translation.json b/extensions/vier-cognitive-voice-gateway/source-translation.json index 680c1358..5f2ea05b 100644 --- a/extensions/vier-cognitive-voice-gateway/source-translation.json +++ b/extensions/vier-cognitive-voice-gateway/source-translation.json @@ -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", @@ -24,9 +22,7 @@ }, "refer": { "nodeLabel": "Refer Call", - "nodeSummary": "Transfer the call to a different destination using SIP REFER", - "inputDestinationLabel": "Destination", - "inputDestinationDescription": "The destination to transfer to (+E.164 number or SIP URI)" + "nodeSummary": "Transfer the call to a different destination using SIP REFER" }, "multipleChoicePrompt": { "nodeLabel": "Get Multiple Choice Answer from Caller", @@ -102,6 +98,8 @@ "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", diff --git a/extensions/vier-cognitive-voice-gateway/src/nodes/forwardCall.ts b/extensions/vier-cognitive-voice-gateway/src/nodes/forwardCall.ts index 8c6adedc..1f6c80e1 100644 --- a/extensions/vier-cognitive-voice-gateway/src/nodes/forwardCall.ts +++ b/extensions/vier-cognitive-voice-gateway/src/nodes/forwardCall.ts @@ -39,8 +39,8 @@ export const forwardCallNode = createNodeDescriptor({ { type: 'cognigyText', key: 'destinationNumber', - label: t.forward.inputDestinationNumberLabel, - description: t.forward.inputDestinationNumberDescription, + label: t.shared.inputDestinationLabel, + description: t.shared.inputDestinationDescription, params: { required: true, }, diff --git a/extensions/vier-cognitive-voice-gateway/src/nodes/referCall.ts b/extensions/vier-cognitive-voice-gateway/src/nodes/referCall.ts index a96aca1e..6974731a 100644 --- a/extensions/vier-cognitive-voice-gateway/src/nodes/referCall.ts +++ b/extensions/vier-cognitive-voice-gateway/src/nodes/referCall.ts @@ -26,8 +26,8 @@ export const referCallNode = createNodeDescriptor({ { type: 'cognigyText', key: 'destination', - label: t.refer.inputDestinationLabel, - description: t.refer.inputDestinationDescription, + label: t.shared.inputDestinationLabel, + description: t.shared.inputDestinationDescription, params: { required: true, placeholder: '+E.164 number or SIP URI', diff --git a/extensions/vier-cognitive-voice-gateway/src/translations.ts b/extensions/vier-cognitive-voice-gateway/src/translations.ts index c436e85a..dc50242f 100644 --- a/extensions/vier-cognitive-voice-gateway/src/translations.ts +++ b/extensions/vier-cognitive-voice-gateway/src/translations.ts @@ -104,14 +104,6 @@ export default { }, }, forward: { - inputDestinationNumberDescription: { - 'default': "Enter the phone number you want to forward the call to (with country code, e.g. +49721480848680).", - 'deDE': "Geben Sie die Rufnummer ein, an die weitergeleitet werden soll (mit Ländervorwahl, z. B. +49721480848680).", - }, - inputDestinationNumberLabel: { - 'default': "Destination Phone Number", - 'deDE': "Ziel-Rufnummer", - }, nodeLabel: { 'default': "Forward Call", 'deDE': "Anruf weiterleiten", @@ -282,17 +274,9 @@ export default { }, }, refer: { - inputDestinationDescription: { - 'default': "Enter the phone number you want to forward the call to (with country code or SIP URI).", - 'deDE': "Geben Sie die Rufnummer ein, an die weitergeleitet werden soll (mit Ländervorwahl oder SIP-URI).", - }, - inputDestinationLabel: { - 'default': "Destination", - 'deDE': "Ziel", - }, nodeLabel: { - 'default': "Forward Call (SIP REFER)", - 'deDE': "Anruf weiterleiten (SIP-REFER)", + 'default': "Use SIP REFER", + 'deDE': "Via SIP-REFER weiterleiten", }, nodeSummary: { 'default': "Forward the call to a different destination using SIP REFER", @@ -301,12 +285,12 @@ export default { }, referService: { nodeLabel: { - 'default': "Check Forward Result", - 'deDE': "Weiterleitungsergbnis prüfen", + 'default': "Check SIP REFER result", + 'deDE': "SIP-REFER-Ergebnis prüfen", }, nodeSummary: { - 'default': "Check the result of the call forward", - 'deDE': "Ergebnis der Anrufweiterleitung prüfen", + 'default': "Check the result of the previous forwarding via SIP REFER", + 'deDE': "Ergebnis der vorangehenden Weiterleitung via SIP-REFER prüfen", }, }, sendData: { @@ -372,6 +356,14 @@ export default { 'default': "Custom Data", 'deDE': "Benutzerdefinierte Daten", }, + inputDestinationDescription: { + 'default': "Enter the destination as a phone number with country code (e.g. +491467...) or as a SIP URI (e.g. sip:user@example.org).", + 'deDE': "Geben Sie das Ziel als Rufnummer mit Ländervorwahl (z. B. +491467...) oder als SIP-URI (z. B. sip:user@example.org) ein.", + }, + inputDestinationLabel: { + 'default': "Destination", + 'deDE': "Ziel", + }, inputEndFlowDescription: { 'default': "To stop the flow after executing this node, activate this checkbox.", 'deDE': "Um den Flow nach der Ausführung dieses Knotens zu stoppen, aktivieren Sie diese Checkbox.", From 4d8abaa91cdd123fa7d94874b5d44f4bcb6fb213 Mon Sep 17 00:00:00 2001 From: Phillip Schichtel Date: Mon, 21 Aug 2023 18:18:10 +0200 Subject: [PATCH 3/3] introduce userToUserInformation support also prepare it for refer, even though the backend doesn't support it yet --- .../vier-cognitive-voice-gateway/package.json | 2 +- .../source-translation.json | 5 +++- .../src/common/transferCall.ts | 23 +++++++++++++------ .../src/helpers/util.ts | 19 +++++++++++++++ .../src/nodes/bridgeCall.ts | 2 ++ .../src/nodes/forwardCall.ts | 2 ++ .../src/nodes/referCall.ts | 13 ++++++++++- .../src/translations.ts | 9 ++++++++ 8 files changed, 65 insertions(+), 10 deletions(-) diff --git a/extensions/vier-cognitive-voice-gateway/package.json b/extensions/vier-cognitive-voice-gateway/package.json index 3a90fc01..5cd7ca68 100644 --- a/extensions/vier-cognitive-voice-gateway/package.json +++ b/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", diff --git a/extensions/vier-cognitive-voice-gateway/source-translation.json b/extensions/vier-cognitive-voice-gateway/source-translation.json index 5f2ea05b..d435434b 100644 --- a/extensions/vier-cognitive-voice-gateway/source-translation.json +++ b/extensions/vier-cognitive-voice-gateway/source-translation.json @@ -86,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", @@ -103,7 +105,8 @@ "childSuccessLabel": "On Success", "childFailureLabel": "On Failure", "childTerminationLabel": "On Termination", - "childDefaultLabel": "Default" + "childDefaultLabel": "Default", + "sectionSipLabel": "SIP" }, "bargeIn": { "input": { diff --git a/extensions/vier-cognitive-voice-gateway/src/common/transferCall.ts b/extensions/vier-cognitive-voice-gateway/src/common/transferCall.ts index ca03361b..e967a829 100644 --- a/extensions/vier-cognitive-voice-gateway/src/common/transferCall.ts +++ b/extensions/vier-cognitive-voice-gateway/src/common/transferCall.ts @@ -11,6 +11,7 @@ import { export interface TransferCallInputs extends EndFlowInputs { callerId?: string; + userToUserInformation?: Array customSipHeaders?: object; ringTimeout?: number; acceptAnsweringMachines?: boolean; @@ -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, @@ -82,6 +90,7 @@ const whisperingTextField: INodeField = { export const transferCallFields: Array = [ callerIdField, customSipHeadersField, + userToUserField, ringTimeoutField, acceptAnsweringMachinesField, dataField, @@ -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, }; @@ -120,7 +129,7 @@ const additionalSettingsSection: INodeSection = { export const transferCallSections: Array = [ callSection, - sipHeadersSection, + sipSection, additionalDataSection, additionalSettingsSection, ]; @@ -131,7 +140,7 @@ export const transferCallForm: Array = [ type: 'section', }, { - key: sipHeadersSection.key, + key: sipSection.key, type: 'section', }, { diff --git a/extensions/vier-cognitive-voice-gateway/src/helpers/util.ts b/extensions/vier-cognitive-voice-gateway/src/helpers/util.ts index 998f52ff..3f5018a8 100644 --- a/extensions/vier-cognitive-voice-gateway/src/helpers/util.ts +++ b/extensions/vier-cognitive-voice-gateway/src/helpers/util.ts @@ -103,6 +103,25 @@ export function normalizeSipHeaders(headersObject: object | undefined): CustomSi return headers; } +export function normalizeUserToUserInformation(userToUserInformation: Array | undefined): Array | undefined { + if (!Array.isArray(userToUserInformation)) { + return undefined; + } + + const information: Array = [] + 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 { diff --git a/extensions/vier-cognitive-voice-gateway/src/nodes/bridgeCall.ts b/extensions/vier-cognitive-voice-gateway/src/nodes/bridgeCall.ts index 2dea3d8f..b247770d 100644 --- a/extensions/vier-cognitive-voice-gateway/src/nodes/bridgeCall.ts +++ b/extensions/vier-cognitive-voice-gateway/src/nodes/bridgeCall.ts @@ -9,6 +9,7 @@ import { normalizeData, normalizeSipHeaders, normalizeText, + normalizeUserToUserInformation, } from '../helpers/util'; import t from '../translations'; import { @@ -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), diff --git a/extensions/vier-cognitive-voice-gateway/src/nodes/forwardCall.ts b/extensions/vier-cognitive-voice-gateway/src/nodes/forwardCall.ts index 1f6c80e1..e68d04d1 100644 --- a/extensions/vier-cognitive-voice-gateway/src/nodes/forwardCall.ts +++ b/extensions/vier-cognitive-voice-gateway/src/nodes/forwardCall.ts @@ -9,6 +9,7 @@ import { normalizeText, convertDurationFromSecondsToMillis, delay, + normalizeUserToUserInformation, } from '../helpers/util'; import t from '../translations'; import { @@ -78,6 +79,7 @@ export const forwardCallNode = createNodeDescriptor({ destinationNumber: normalizeText(config.destinationNumber), callerId: normalizeText(config.callerId), customSipHeaders: normalizeSipHeaders(config.customSipHeaders), + userToUserInformation: normalizeUserToUserInformation(config.userToUserInformation), ringTimeout: convertDurationFromSecondsToMillis(config.ringTimeout), acceptAnsweringMachines: config.acceptAnsweringMachines, data: normalizeData(api, config.data), diff --git a/extensions/vier-cognitive-voice-gateway/src/nodes/referCall.ts b/extensions/vier-cognitive-voice-gateway/src/nodes/referCall.ts index 6974731a..72c01709 100644 --- a/extensions/vier-cognitive-voice-gateway/src/nodes/referCall.ts +++ b/extensions/vier-cognitive-voice-gateway/src/nodes/referCall.ts @@ -1,10 +1,16 @@ import { INodeFunctionBaseParams, createNodeDescriptor } from "@cognigy/extension-tools"; import t from '../translations'; -import { normalizeText } from "../helpers/util"; +import { + normalizeSipHeaders, + normalizeText, + normalizeUserToUserInformation, +} from "../helpers/util"; import { EndFlowInputs, endFlowField } from "../common/shared"; interface IReferCallInputs extends EndFlowInputs { destination: string; + userToUserInformation?: Array + customSipHeaders?: object; } export interface IReferCallParams extends INodeFunctionBaseParams { @@ -33,6 +39,9 @@ export const referCallNode = createNodeDescriptor({ placeholder: '+E.164 number or SIP URI', }, }, + // TODO enable these once CVG supports them + // userToUserField, + // customSipHeadersField, endFlowField, ], preview: { @@ -45,6 +54,8 @@ export const referCallNode = createNodeDescriptor({ const payload = { status: 'refer', destination: normalizeText(config.destination), + customSipHeaders: normalizeSipHeaders(config.customSipHeaders), + userToUserInformation: normalizeUserToUserInformation(config.userToUserInformation), }; api.say('', payload); diff --git a/extensions/vier-cognitive-voice-gateway/src/translations.ts b/extensions/vier-cognitive-voice-gateway/src/translations.ts index dc50242f..659efdc7 100644 --- a/extensions/vier-cognitive-voice-gateway/src/translations.ts +++ b/extensions/vier-cognitive-voice-gateway/src/translations.ts @@ -428,6 +428,12 @@ export default { 'default': "Timeout", 'deDE': "Zeitüberschreitung", }, + inputUserToUserDescription: { + 'default': "A list of opaque strings that are send as User-To-User SIP headers.", + }, + inputUserToUserLabel: { + 'default': "User-To-User Information", + }, inputWhisperingTextDescription: { 'default': "Enter the text that should be announced to the agent the call is forwarded to before the call partners are connected.", 'deDE': "Geben Sie den Text ein, der dem:der Agent:in bei der Weiterleitung angesagt werden soll, bevor die Gesprächspartner:innen verbunden werden.", @@ -436,6 +442,9 @@ export default { 'default': "Whispering Announcement", 'deDE': "Whispering-Ansage", }, + sectionSipLabel: { + 'default': "SIP", + }, sectionStopConditionLabel: { 'default': "Stop Condition", 'deDE': "Stoppbedingung",