Real-world patterns across industries. Each example shows how the three-manager architecture eliminates context bugs and enables clean multi-UI coordination.
CRM · Chat + Form Coordination · Entity Context
CRM Sales Rep Support Chat
A sales rep opens a chat with a customer. EdgeInteract carries the customer entity context in every message — the AI knows who the customer is, their tier, and their order history without any lookup.
// Set the customer entity context when opening their record
client.state.setEntity({
role: 'entity',
type: 'customer',
id: 'cust-acme-12345',
displayName: 'Acme Corporation',
data: {
creditLimit: 50000,
tier: 'gold',
accountManager: 'rep-789',
openOrders: 3
}
});
// Now send a message — entity.data is in every message automatically
await client.players.chat('conv-acme-deal').sendMessage({
text: 'Can we discuss the outstanding orders?',
type: 'user'
});
// Bot handler receives — no context lookup needed
function handleMessage(msg: IContextualMessage) {
const { entity, user, variables } = msg.context;
// entity.data.tier === 'gold' → route to priority support queue
// entity.data.creditLimit → validate order amount
// user.permissions → check if rep can approve discount
}
Entity context
ICrmAccountEntity extends IEntityIdentityData with salesStage, dealValue, accountManager. The domain sample package provides these types pre-built for CRM use cases.
UI coordination
When the customer mentions an order number, the bot triggers client.players.form('order-detail').display() — the form is pre-filled with entity data. Chat and form stay in sync via PlayerManager.
Permission enforcement
The validation hook reads context.user.permissions on every message. A rep without 'approve-discounts' gets a clear error before the message reaches the backend — no server round-trip needed.
Context isolation
The conversation filter on conv-acme-deal ensures Rep A's messages about Acme never reach Rep B's subscriber for a different customer — even if both reps are online simultaneously.
Result: Sales reps see customer data in every response without any manual lookup. Zero context-leakage incidents between concurrent customer sessions.
A clinician opens a patient record. The patient entity context flows through every chat message, form submission, and workflow step — allergies, medications, and permissions are always available without repeated lookups.
Every message filtered by context.conversation.id — patient Wilson's consultation messages are completely isolated from patient Jones in the adjacent room, even on the same server.
Allergy check in pipeline
The prescription workflow hook reads context.entity.data.allergies and context.entity.data.currentMedications to run drug interaction checks before the prescription is created — no API lookup needed.
Permission enforcement
A nurse without 'write-prescription' gets blocked at the validation hook. The same workflow works correctly for both roles — the hook reads context.user.permissions, not role string comparisons.
Audit trail
Every step logged with patientId, clinicianId, timestamp, and hook results. Complete audit trail for HIPAA compliance — automatically, from the context carried in every message.
Result: Clinicians have full patient context in every interaction. Allergy and drug interaction checks run automatically. Full audit trail for HIPAA without extra instrumentation.
E-Commerce · Multi-UI Coordination · Order Entity
Customer Order Support — Chat + Form + Workflow
A customer contacts support about an order. EdgeInteract coordinates three UIs simultaneously — the chat window, an order detail form, and a return/refund workflow — all sharing the same order entity context.
// Set order entity when customer opens order support
client.state.setEntity({
role: 'entity',
type: 'order',
id: 'ord-88234',
displayName: 'Order #88234',
data: {
status: 'shipped',
trackingNumber: 'UPS-12345XYZ',
items: [{ sku: 'WH-2000', qty: 1, price: 349.99 }],
estimatedDelivery: '2026-04-15',
paymentMethod: 'card-ending-4521'
}
});
// Coordinate three UIs simultaneously
await client.ui.coordinateUIs([
// Show chat with pre-loaded context
{ componentId: 'support-chat', action: 'show' },
// Show order detail form — pre-filled from entity
{ componentId: 'order-detail-form', action: 'display',
metadata: { orderId: 'ord-88234', readOnly: true }},
// Show return workflow (hidden until needed)
{ componentId: 'return-workflow', action: 'initialize',
metadata: { orderId: 'ord-88234' }}
]);
// When customer requests return — activate workflow
await client.players.workflow('return-workflow').execute({
reason: 'defective',
// order status, payment method, items — all from context
});
coordinateUIs()
coordinateUIs() sends operations to multiple UI components in a single call. All three UIs (chat, form, workflow) activate simultaneously with the same order context — no sequential calls, no state synchronisation code.
Entity-prefilled form
The AtlasFormsPlugin reads context.entity.data to pre-fill the order detail form. Tracking number, items, payment method — already populated when the form appears. The customer sees their order immediately.
Workflow state machine
The return workflow uses WorkflowPlayerPlugin's IDLE → RUNNING → COMPLETED state machine. Each step carries the order entity — refund amount calculated from entity.data.items, reversal sent to entity.data.paymentMethod.
broadcastStateChange()
When the workflow completes, broadcastStateChange('order.status', 'return-initiated') updates all three UI components simultaneously — chat shows confirmation, form shows updated status, workflow shows completion.
Result: Three UIs coordinated from a single API. 40% reduction in support call handling time. Zero "wrong order" incidents from manual data entry.
A loan officer processes an application. Context enhancers add credit score, risk tier, and compliance flags to every message — the validation pipeline enforces compliance rules using context, with no code in individual handlers.
// Context enhancer — adds credit and compliance data to every message
class ComplianceEnhancer implements IContextEnhancer {
name = 'compliance';
priority = 5; // Runs first
async enhance(context: IContextualMessage): Promise {
const applicantId = context.context.entity?.id;
if (!applicantId) return context;
const [creditData, complianceFlags] = await Promise.all([
fetchCreditScore(applicantId),
checkComplianceFlags(applicantId)
]);
return {
...context,
context: {
...context.context,
variables: {
...context.context.variables,
creditScore: creditData.score, // 750
riskTier: creditData.tier, // 'low'
amlFlag: complianceFlags.aml, // false
kycComplete: complianceFlags.kyc, // true
maxLoanAmount: creditData.maxApproval // 250000
}
}
};
}
}
client.state.addEnhancer(new ComplianceEnhancer());
// Validation hook — enforces rules using context variables
// (No knowledge of HOW compliance data was fetched)
function loanValidationHook(context: IContextualMessage) {
if (!context.context.variables?.kycComplete) {
throw new Error('KYC verification required before loan processing');
}
if (context.context.variables?.amlFlag) {
throw new Error('AML flag requires compliance review');
}
if (body.amount > context.context.variables?.maxLoanAmount) {
throw new Error(`Amount exceeds approved limit of ${context.context.variables.maxLoanAmount}`);
}
}
Separation of concerns
The enhancer fetches compliance data once. The validation hook enforces rules. Neither knows about the other. Adding a new compliance check means adding a new enhancer — not touching validation code.
Parallel data fetching
The enhancer uses Promise.all() to fetch credit score and compliance flags simultaneously. The enriched context is ready before any hook or handler runs — efficient and clean.
Audit trail
Every message logged with the full context snapshot — including creditScore, riskTier, amlFlag. Regulatory audits have a complete, timestamped record of what data was available at the time of each decision.
Form + workflow integration
The Atlas Forms plugin renders the loan application form. The Flow Engine workflow handles multi-step approval. EdgeInteract carries the same compliance context through both — no data re-fetching or manual passing between systems.
Result: Compliance checks run automatically on every message. AML/KYC enforcement without any handler-level code. Complete audit trail for regulatory review.
Ready to build context-aware applications?
Start with the get-started guide or explore the architecture.