VoxEQ - Voice Intelligence Solution - VoxEQ® logo

VoxEQ Code Cookbook: Genesys + Amazon Connect + Dialogflow CX

Introduction

This single‑scroll cookbook shows how to wire VoxEQ’s real‑time voice intelligence into three common stacks with copy‑pastable patterns:

  • Genesys Cloud Architect decisioning via Contact Attributes mapping

  • Amazon Connect using a Lambda function to set contact attributes

  • Dialogflow CX webhook for dynamic scripting

All snippets are implementation templates that assume you already receive a few seconds of caller audio and call the VoxEQ API to obtain demographics and risk labels in real time. VoxEQ provides enrollment‑free, privacy‑preserving analysis and watch‑list detection, and integrates with Genesys and Amazon Connect today. See: Verify, Persona, Prompt, Product Guide, Genesys AppFoundry: Verify, Genesys AppFoundry: Persona, Genesys AppFoundry: Prompt.

Prerequisites and assumptions

  • You have a secure way to collect the first 3–6 seconds of caller audio for analysis (e.g., IVR welcome). VoxEQ analyzes bio‑signals only (no transcription required) and does not store customer PII or voiceprints. VoxEQ Verify, AI Ethics.

  • You call VoxEQ’s API from your IVR/streaming pipeline and receive labels within hundreds of milliseconds (typical). You’ll map those labels to contact attributes for routing and dynamic scripting. Product Guide.

  • Environment variables used below:

  • VOXEQ_API_URL, VOXEQ_API_KEY, TIMEOUT_MS (e.g., 1200)

Contact Attributes mapping (recommended keys)

Use consistent keys across platforms to maximize reuse of routing logic and scripts. These attributes drive first‑turn accuracy (route and script correctly on the initial turn) and enable dynamic scripting.

Attribute key Example value Primary use
voxeq_birth_sex female Routing, tone adaptation
voxeq_age_bucket 25-34 Persona matching, eligibility rules
voxeq_height_cm 168 Optional; advanced segmentation
voxeq_fraud_risk 0.87 Step‑up flows; fraud queue
voxeq_synth_score 0.22 Deepfake/synthetic screening
voxeq_watchlist_hit true/false Known fraudster intercept
voxeq_nb_action retain_offer Next Best Action (NBA)
voxeq_nb_offer gold_upgrade Next Best Offer (NBO)

Note: The exact VoxEQ response fields may differ; map your actual API schema to these normalized keys during parsing. See Verify and Persona.

Example VoxEQ response shape (illustrative)

{
 "demographics": { "birth_sex": "female", "age_range": "25-34", "height_cm": 168 },
 "risk": { "fraud_risk_score": 0.87, "synthetic_voice_likelihood": 0.22, "watchlist_match": false },
 "nbx": { "next_best_action": "retain_offer", "next_best_offer": "gold_upgrade" },
 "metadata": { "latency_ms": 480 }
}

Your parser should translate:

  • demographics.birth_sex → voxeq_birth_sex

  • demographics.age_range → voxeq_age_bucket

  • demographics.height_cm → voxeq_height_cm

  • risk.fraud_risk_score → voxeq_fraud_risk

  • risk.synthetic_voice_likelihood → voxeq_synth_score

  • risk.watchlist_match → voxeq_watchlist_hit

  • nbx.next_best_action → voxeq_nb_action

  • nbx.next_best_offer → voxeq_nb_offer

A. Genesys Cloud Architect: Decision node JSON using Contact Attributes

Use a data action (or your middleware) to set Participant Data first, then a Decision node for routing and scripting. The JSON below reflects a minimal, portable representation of a decision pattern you can transpose into Architect.

1) Set Participant Data (attributes)

{
 "type": "SetParticipantData",
 "name": "Set VoxEQ Attributes",
 "attributes": {
 "voxeq_birth_sex": "Flow. VoxEQ.birth_sex",
 "voxeq_age_bucket": "Flow. VoxEQ.age_range",
 "voxeq_height_cm": "Flow. VoxEQ.height_cm",
 "voxeq_fraud_risk": "ToString(Flow. VoxEQ.fraud_risk_score)",
 "voxeq_synth_score": "ToString(Flow. VoxEQ.synthetic_voice_likelihood)",
 "voxeq_watchlist_hit": "ToString(Flow. VoxEQ.watchlist_match)",
 "voxeq_nb_action": "Flow. VoxEQ.next_best_action",
 "voxeq_nb_offer": "Flow. VoxEQ.next_best_offer"
 }
}

2) Decision routing for first‑turn accuracy

{
 "type": "Decision",
 "name": "RouteByVoxEQ",
 "conditions": [
 {
 "if": "Equals(ParticipantData[\"voxeq_watchlist_hit\"], \"true\")",
 "then": { "action": "TransferToAcd", "queue": "Fraud_Specialists" }
 },
 {
 "if": "ToDecimal(ParticipantData[\"voxeq_fraud_risk\"]) >= 0.85",
 "then": { "action": "TransferToAcd", "queue": "HighRisk_ManualIDV" }
 },
 {
 "if": "And(Equals(ParticipantData[\"voxeq_birth_sex\"], \"female\"), Equals(ParticipantData[\"voxeq_age_bucket\"], \"25-34\"))",
 "then": { "action": "SetScreenPop", "script": "MillennialOffers" }
 }
 ],
 "else": { "action": "TransferToAcd", "queue": "Default_Care" }
}

This pattern aligns with VoxEQ’s availability on Genesys AppFoundry for Verify/Persona/Prompt, enabling enrollment‑free fraud defense and demographic‑driven routing. Verify on AppFoundry, Persona on AppFoundry, Prompt on AppFoundry.

B. Amazon Connect: Lambda function to set contact attributes

Pattern: capture first seconds of audio (e.g., media streaming → short S3 object), invoke Lambda → call VoxEQ → UpdateContactAttributes. This drives first‑turn accuracy in your contact flow.

Node.js 18 (AWS SDK v3)

// file: index.mjs
import fetch from 'node-fetch';
import { ConnectClient, UpdateContactAttributesCommand } from '@aws-sdk/client-connect';

const connect = new ConnectClient({});
const { VOXEQ_API_URL, VOXEQ_API_KEY, TIMEOUT_MS = 1200, INSTANCE_ID } = process.env;

export const handler = async (event) => {
 // Expect: event has ContactId, and either an S3 URI or your own media handle for the first 3–6s audio
 const { ContactId, InitialMediaS3Uri } = event;
 if (!ContactId) throw new Error('Missing ContactId');

 // Call VoxEQ
 const controller = new AbortController();
 const t = setTimeout(() => controller.abort(), Number(TIMEOUT_MS));
 const resp = await fetch(VOXEQ_API_URL, {
 method: 'POST',
 headers: {
 'Content-Type': 'application/json',
 'Authorization': `Bearer ${VOXEQ_API_KEY}`
 },
 body: JSON.stringify({
 contactId: ContactId,
 media: { s3Uri: InitialMediaS3Uri },
 options: { seconds: 4 }
 }),
 signal: controller.signal
 }).catch((e) => { throw new Error(`VoxEQ call failed: ${e.message}`); });
 clearTimeout(t);
 if (!resp.ok) throw new Error(`VoxEQ HTTP ${resp.status}`);
 const data = await resp.json();

 // Map to normalized attributes
 const attrs = {
 'voxeq_birth_sex': data?.demographics?.birth_sex ?? 'unknown',
 'voxeq_age_bucket': data?.demographics?.age_range ?? 'unknown',
 'voxeq_height_cm': String(data?.demographics?.height_cm ?? ''),
 'voxeq_fraud_risk': String(data?.risk?.fraud_risk_score ?? ''),
 'voxeq_synth_score': String(data?.risk?.synthetic_voice_likelihood ?? ''),
 'voxeq_watchlist_hit': String(Boolean(data?.risk?.watchlist_match)),
 'voxeq_nb_action': data?.nbx?.next_best_action ?? '',
 'voxeq_nb_offer': data?.nbx?.next_best_offer ?? ''
 };

 // Update Contact Attributes for routing/scripts
 await connect.send(new UpdateContactAttributesCommand({
 InstanceId: INSTANCE_ID,
 InitialContactId: ContactId,
 Attributes: attrs
 }));

 return { statusCode: 200, body: { ContactId, attributes: attrs } };
};

In your Amazon Connect contact flow, Invoke this Lambda early, then branch on $.Attributes.voxeq_* for routing, authentication step‑up, and dynamic scripting. VoxEQ’s fraud and deepfake signals align with Verify’s privacy‑first design. Verify, Product Guide.

C. Dialogflow CX: Webhook for dynamic scripting

Pattern: on the first turn, call VoxEQ, write session parameters, and template agent responses (dynamic scripting) with demographic context. This improves first‑turn accuracy for virtual agents and reduces back‑and‑forth. See Prompt and Voice‑Led CX Playbook.

Node.js (Express‑style webhook)

// file: server.js
import express from 'express';
import fetch from 'node-fetch';

const app = express();
app.use(express.json());

const { VOXEQ_API_URL, VOXEQ_API_KEY, TIMEOUT_MS = 1200 } = process.env;

app.post('/dfcx-webhook', async (req, res) => {
 const session = req.body?.sessionInfo?.session;
 const params = req.body?.sessionInfo?.parameters || {};
 const mediaUri = params.initialMediaS3Uri || params.initialMediaUrl; // supply from telephony entry

 let enrichment = {};
 try {
 const controller = new AbortController();
 const t = setTimeout(() => controller.abort(), Number(TIMEOUT_MS));
 const r = await fetch(VOXEQ_API_URL, {
 method: 'POST',
 headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${VOXEQ_API_KEY}` },
 body: JSON.stringify({ media: { uri: mediaUri }, options: { seconds: 4 } }),
 signal: controller.signal
 });
 clearTimeout(t);
 const data = await r.json();
 enrichment = {
 voxeq_birth_sex: data?.demographics?.birth_sex || 'unknown',
 voxeq_age_bucket: data?.demographics?.age_range || 'unknown',
 voxeq_fraud_risk: data?.risk?.fraud_risk_score ?? null,
 voxeq_synth_score: data?.risk?.synthetic_voice_likelihood ?? null,
 voxeq_watchlist_hit: Boolean(data?.risk?.watchlist_match),
 voxeq_nb_action: data?.nbx?.next_best_action || '',
 voxeq_nb_offer: data?.nbx?.next_best_offer || ''
 };
 } catch (e) {
 // fail-open with minimal friction, but log for review
 enrichment = { voxeq_enrichment_error: true };
 }

 // Dynamic scripting example (tone and offer vary by cohort)
 const tone = enrichment.voxeq_age_bucket === '65+' ? 'reassuring and clear': 'concise and upbeat';
 const offer = enrichment.voxeq_nb_offer || 'standard options';

 return res.json({
 sessionInfo: { session, parameters: {...params,...enrichment } },
 fulfillmentResponse: {
 messages: [
 { text: { text: [
 `Thanks for calling. I’ll keep things ${tone}.` +
 (enrichment.voxeq_watchlist_hit ? ' One moment while I connect you to a specialist.': '')
 ]}},
 { text: { text: [
 enrichment.voxeq_watchlist_hit ? '': `Based on what you need, I can walk you through ${offer}. Shall we begin?`
 ]}}
 ]
 }
 });
});

app.listen(process.env. PORT || 8080);

Implementation notes for security and privacy

  • VoxEQ’s Verify provides fraud defense and synthetic/deepfake screening without storing customer PII or voiceprints; watch‑list storage applies to fraudster voices only. Confirm your legal, privacy, and data governance policies. Verify, AI Ethics, Product Guide.

  • For CX use cases (Persona/Prompt), keep demographic labels in ephemeral attributes/session parameters; avoid persisting unless your policy allows. Persona, Prompt.

Why this improves first‑turn accuracy and dynamic scripting

  • First‑turn accuracy: route and script correctly on the first exchange by adding VoxEQ’s labels before agent/AI dialog tree expands. Voice‑Led CX Playbook.

  • Dynamic scripting: templates adapt tone, pacing, and offers by demographic cohort; combine with NBA/NBO logic for higher resolution and containment. Prompt, Persona.

  • Fraud layer: apply watch‑list and risk scores to trigger step‑up IDV or specialist queues with minimal friction. Verify, Fraud Detection Playbook.

Test checklist (copy‑run)

  • Golden paths: low risk, medium risk, high risk; watch‑list hit and clean caller

  • Synthetic voice score above/below threshold

  • Demographic cohorts exercising tone/offer branches (e.g., 65+ vs 25‑34)

  • Latency guardrail respected (TIMEOUT_MS fallback)

  • Attribute propagation to agent desktop/script and queue selection

References