A Node.js demonstration server that integrates VideoEngager video meetings with Genesys Cloud callback scheduling while maintaining customer data privacy.
This integration creates a seamless experience where customers can schedule both a video meeting and a phone callback simultaneously. The system maintains data privacy by using anonymous customer IDs for external API calls while securely storing PII on your servers.
Before you begin, ensure you have:
# Clone the repository
git clone https://github.com/VideoEngager/videoengager.github.io.git
cd examples/genesys-node-demonstration
# Install dependencies
npm install
Copy the example environment file and configure your settings:
cp .env.example .env
Edit .env
with your configuration:
# Server Configuration
PORT=3002
NODE_ENV=development
# VideoEngager Configuration
VE_DOMAIN=dev.videoengager.com
VE_PAK=your-partner-access-key
VE_EXTERNAL_ID=your-external-id
VE_EMAIL=your-authorized-email@company.com
# Genesys Cloud Configuration
GENESYS_ENVIRONMENT=mypurecloud.com
GENESYS_CLIENT_ID=your-oauth-client-id
GENESYS_CLIENT_SECRET=your-oauth-client-secret
GENESYS_QUEUE_ID=your-queue-id
GENESYS_SCRIPT_ID=your-script-id
# Development mode with auto-reload
npm run dev
# Production mode
npm start
The server will start on http://localhost:3002
(or your configured PORT).
dev.videoengager.com
- Development/testingstaging.videoengager.com
- Staging environmentvideome.leadsecure.com
- Production environmentcurl "https://dev.videoengager.com/api/partners/impersonate/YOUR_PAK/YOUR_EXTERNAL_ID/YOUR_EMAIL"
client_credentials
grant typeconversations:callback:create
conversations:callback:read
curl -X POST "https://login.mypurecloud.com/oauth/token" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "grant_type=client_credentials&client_id=YOUR_CLIENT_ID&client_secret=YOUR_CLIENT_SECRET"
Schedules both a VideoEngager meeting and Genesys callback.
Request Body:
{
"firstName": "John",
"lastName": "Doe",
"phoneNumber": "+1-555-123-4567",
"subject": "Product inquiry",
"desiredTime": "2024-12-25T15:30:00.000Z"
}
Success Response (200):
{
"success": true,
"customerId": "cust_abc123",
"videoUrl": "https://dev.videoengager.com/ve/meeting123",
"callbackId": "conv-456-789",
"scheduledTime": "2024-12-25T15:30:00.000Z",
"message": "Callback and video meeting scheduled successfully"
}
Error Response (400/500):
{
"error": "Invalid request data",
"details": ["Phone number is required"],
"requestId": "req-123-456"
}
Returns system health and service status.
Response:
{
"status": "healthy",
"timestamp": "2024-12-25T12:00:00.000Z",
"version": "1.0.0",
"environment": "development",
"uptime": 3600,
"services": {
"videoEngager": { "status": "healthy" },
"genesys": { "status": "healthy" }
}
}
Retrieves customer data by anonymous ID (for testing/admin purposes).
sequenceDiagram
participant C as Customer
participant S as Your Server
participant VE as VideoEngager API
participant G as Genesys API
C->>S: POST /api/schedule-callback<br/>{firstName, lastName, phoneNumber, subject, desiredTime}
Note over S: 1. Validate Input Data
alt Invalid Data
S->>C: 400 Bad Request<br/>{error: "Invalid request data", details: [...]}
end
Note over S: 2. Generate Anonymous ID<br/>customerId = "cust_abc123"
Note over S: 3. Store PII Securely<br/>Map customerId โ {firstName, lastName, phoneNumber}
Note over S: 4. Create VideoEngager Meeting
S->>VE: GET /api/partners/impersonate/{PAK}/{externalId}/{email}
alt Auth Failed
VE->>S: 401/403 Authentication Error
S->>C: 500 Internal Error<br/>"Video meeting system unavailable"
else Auth Success
VE->>S: 200 OK<br/>{token: "jwt_token"}
S->>VE: POST /api/schedules/my/<br/>Authorization: Bearer {token}<br/>{customerId: "cust_abc123", date: timestamp, duration: 30}
alt Meeting Creation Failed
VE->>S: 400/500 Error
S->>C: 500 Internal Error<br/>"Failed to create video meeting"
else Meeting Created
VE->>S: 200 OK<br/>{_id: "meeting123", visitor: {meetingUrl: "..."}}
end
end
Note over S: 5. Schedule Genesys Callback
S->>G: POST /oauth/token<br/>{grant_type: "client_credentials", client_id, client_secret}
alt Auth Failed
G->>S: 401 Authentication Error
S->>C: 500 Internal Error<br/>"Callback system unavailable"
else Auth Success
G->>S: 200 OK<br/>{access_token: "oauth_token"}
S->>G: POST /api/v2/conversations/callbacks<br/>Authorization: Bearer {token}<br/>{phoneNumber, queueId, scriptId, scheduledTime, data: {customerId, veScheduleId}}
alt Callback Failed
G->>S: 400/500 Error
S->>C: 500 Internal Error<br/>"Failed to schedule callback"
else Callback Created
G->>S: 200 OK<br/>{conversation: {id: "conv-456"}}
end
end
Note over S: 6. Link Meeting to Callback
S->>VE: PUT /api/schedules/my/{meetingId}<br/>Authorization: Bearer {token}<br/>{conversationId: "conv-456"}
alt Patch Failed
VE->>S: 400/500 Error
Note over S: Log warning, continue
else Patch Success
VE->>S: 200 OK<br/>{_id: "meeting123", conversationId: "conv-456"}
end
Note over S: 7. Return Success
S->>C: 200 OK<br/>{success: true, customerId: "cust_abc123", videoUrl: "...", callbackId: "conv-456"}
http://localhost:3002
in your browser# Test callback scheduling
curl -X POST http://localhost:3002/api/schedule-callback \
-H "Content-Type: application/json" \
-d '{
"firstName": "Test",
"lastName": "User",
"phoneNumber": "+1-555-123-4567",
"subject": "API Test",
"desiredTime": "2024-12-25T15:30:00.000Z"
}'
# Test health endpoint
curl http://localhost:3002/api/health
VideoEngager:
Genesys Cloud:
1. Authentication Errors
Error: Failed to authenticate with VideoEngager
2. Genesys OAuth Errors
Error: Failed to authenticate with Genesys
client_credentials
grant type3. Queue/Script Not Found
Error: Queue not found or Script not found
4. Port Already in Use
Error: EADDRINUSE: address already in use :::3002
pkill -f node
Enable detailed logging:
LOG_LEVEL=debug npm start
Check logs in logs/
directory:
combined.log
- All log entrieserror.log
- Errors onlyaccess.log
- Request logsMonitor service health:
# Check if services are responding
curl http://localhost:3002/api/health
# Test VideoEngager connectivity
curl "https://dev.videoengager.com/api/partners/impersonate/YOUR_PAK/YOUR_EXTERNAL_ID/YOUR_EMAIL"
# Test Genesys connectivity
curl -X POST "https://login.mypurecloud.com/oauth/token" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "grant_type=client_credentials&client_id=YOUR_CLIENT_ID&client_secret=YOUR_CLIENT_SECRET"
โโโ config/
โ โโโ environment.js # Environment validation
โโโ middleware/
โ โโโ security.js # Security middleware
โโโ services/
โ โโโ videoEngager.js # VideoEngager API integration
โ โโโ genesys.js # Genesys Cloud API integration
โโโ storage/
โ โโโ customerData.js # Customer data storage
โโโ utils/
โ โโโ logger.js # Centralized logging
โโโ validators/
โ โโโ callbackValidator.js # Input validation
โโโ public/
โ โโโ index.html # Frontend form
โ โโโ js/
โ โโโ script.js # Frontend JavaScript
โโโ logs/ # Application logs
โโโ index.js # Main server file
โโโ .env.example # Environment template
โโโ README.md # This file
NODE_ENV=production
VE_DOMAIN=videome.leadsecure.com
GENESYS_ENVIRONMENT=mypurecloud.com
LOG_LEVEL=warn
Replace in-memory storage with persistent database:
For enterprise support and custom integrations, contact VideoEngager Support support@videoengager.com directly.
This project is licensed under the MIT License. See LICENSE.md for details.
Note: This is a demonstration integration. For production use, implement proper database storage, enhanced security measures, and comprehensive error handling.