How salesforce-misc/byo-demo-connector works
Main Components
a. Frontend (Browser UI)
• Static HTML pages in /public (e.g. app.html, ccaas.html, ottapp.html, remote.html, etc.)
• Bundled JavaScript modules built by Webpack:
• src/login – handles authentication UI
• src/byo-ott-app – OTT (Messaging) UI logic
• src/remote-control – Voice simulation UI logic
• src/common – shared constants and utils
• src/main/connector.js & src/main/vendor-sdk.js – core connector logic injected into the page
• src/hid – optional USB‐HID device integration (Jabra, Plantronics parsers)
b. Backend (Node.js Server)
• Entry point: src/server/server.mjs
• Authentication & Salesforce API layer:
• src/server/ottAppLib/sfdc-auth.mjs – JWT/OAuth2 handshake
• src/server/ottAppLib/pubsub_api.proto + sfdc-pub-sub-api.mjs – Pub/Sub streaming
• Voice Connector:
• src/server/scrtConnector.mjs – interfaces with SCRT2 telephony service
• src/server/ottAppServer.mjs – HTTP endpoints for voice simulation
• Utilities & configuration: messaging constants, certs (private.key, cert.pem), env var loader
c. Apex Mock Server (Salesforce Code)
• /src/apex folder contains Salesforce Apex classes & tests that mock a telephony API
• Deployed to a test Salesforce org to simulate Service Cloud Voice behavior
d. Salesforce Cloud Services (External)
• OAuth2 Token Endpoint (login.salesforce.com, test.salesforce.com, or custom dev instance)
• Service Cloud Voice/SCRT2 telephony integration service
• Service Cloud Messaging Pub/Sub endpoint (api.pubsub.salesforce.com:7443)
e. Build & Deployment Pipeline
• Webpack (webpack.config.js) – bundles the frontend assets, enables HTTPS dev server
• Gulp (gulpfile.js) – bundle tasks for production/minified connector
• Jest (jest-report) – unit tests for server & vendor-sdk
• Jenkinsfile – CI/CD orchestration
Relationships & Data Flows
• Browser UI ←HTTPS→ Node.js Server
• Voice Tab UI calls /voice endpoints on server for making/answering calls
• Messaging Tab UI uses vendor-SDK to subscribe/publish messages via server
• Node.js Server ←→ Salesforce
• OAuth2 handshake to obtain access token
• Pub/Sub subscription to receive inbound messages
• SCRT2 connector to post voice events & receive telephony callbacks
• Node.js Server ←→ Apex Mocks (deployed in Salesforce)
• Simulated telephony API endpoints for Partner Telephony demo
• Optional: Browser UI ←→ USB HID devices via src/hid
Architectural Patterns & Principles
• Modular separation: distinct folders for UI modules (byo-ott, remote-control), server support libs (ottAppLib), mock apex code
• Connector pattern: a thin client‐side connector that delegates all heavy lifting to the Node server
• Single Page App served by Webpack Dev Server over HTTPS for CORS compliance
• Secure JWT/OAuth flows with private/public key (self-signed cert for local dev)
Technologies & Frameworks
• Node.js (ESM .mjs modules)
• Webpack & webpack-dev-server (HTTPS, hot reload)
• Gulp for bundling
• Jest for unit testing
• JSDoc (/docs) for API documentation
• Salesforce Pub/Sub gRPC-style .proto integration
• Apex classes in Salesforce compiler/meta XML