Fraud Detection
A finance team monitors transactions in real time to detect potentially fraudulent activities. When a suspicious transaction is detected, the workflow broadcasts a fraud alert, enriches the alert with additional risk-scoring details (using a Delivery Hook), and then escalates the issue to a compliance or investigation application via an outbound Action. Finally, a Receptor listens for escalated alerts to trigger manual or automated follow-up actions, ensuring rapid remediation.
Sequence Diagram
Below is a Mermaid sequence diagram that outlines the key steps and interactions:
Components Description:
- Fraud Monitor Application (Agent SDK): Initiates the detection of suspicious activities and broadcasts a base context.
- DeliveryHook: Intercepts the broadcast to enrich the fraud context with additional risk scoring or meta data.
- FraudAction (Outbound Action): Uses a Deep Link or REST API call to escalate the fraud alert.
- Compliance Application (Receptor): Receives the escalation and notifies the compliance team or triggers an investigation workflow.
Implementation Patterns & Code
Below are some TypeScript code examples demonstrating key parts of the workflow.
1. Agent SDK: Broadcasting the Suspicious Transaction
import { DesktopAgent, Context } from '@finos/fdc3';
import { createAgent } from "https://platform.connectifi.app/agent/main.bundle.js";
(async () => {
// Initialize the Agent using the Connectifi platform
const agent: DesktopAgent = await createAgent('https://platform.connectifi.app', 'FINANCE_APP@DIRECTORY');
// Listener for any fraud notifications (if needed)
agent.addContextListener('fdc3.fraud.notification', (context: Context) => {
console.log('Fraud alert received:', context);
});
// Function to broadcast a suspicious transaction context
const broadcastSuspiciousTransaction = async () => {
const suspiciousTransactionContext: Context = {
type: 'fdc3.transaction.suspicious',
data: {
transactionId: 'TX-98765',
amount: 100000,
currency: 'USD',
timestamp: Date.now(),
}
};
// Broadcast the suspicious transaction context.
await agent.broadcast(suspiciousTransactionContext);
};
// Trigger the broadcast
await broadcastSuspiciousTransaction();
})();
2. Implementing a Delivery Hook for Context Enrichment
import { type Context, ContextTypes } from '@finos/fdc3';
import type { DeliveryHookHandler } from '@connectifi/sdk';
import { RequestError } from '../types';
export const enrichFraudContextHook: DeliveryHookHandler = async (request) => {
const { context } = request;
// Check that the context is of the expected type
if (context.type !== 'fdc3.transaction.suspicious') {
throw new RequestError('Context type not supported for fraud enrichment');
}
// Add a risk score and additional metadata for the fraud context
const enrichedContext: Context = {
...context,
data: {
...context.data,
riskScore: calculateRiskScore(context.data), // implement your risk logic
enrichedBy: 'FraudEnrichmentService',
},
};
return { context: enrichedContext };
};
function calculateRiskScore(data: any): number {
// Example risk calculation logic
// In real applications, integrate with an ML model or rule-based system.
return data.amount > 50000 ? 90 : 50;
}
3. Outbound Action: Escalating Suspicious Transactions
import type { DataActionHandler } from '@connectifi/sdk';
import type { Context } from '@finos/fdc3';
const apiKey = process.env.FRAUD_ESCLATION_API_KEY;
export const escalateFraudAction: DataActionHandler = async (request) => {
const { context, intent } = request;
if (!apiKey) {
throw new Error('Escalation service API key is missing');
}
if (intent !== 'EscalateFraud') {
throw new Error('Intent not supported');
}
// Call an external fraud escalation or compliance service
const response = await fetch(`https://fraud-escalation.example.com/escalate?apiKey=${apiKey}`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(context),
});
if (!response.ok) {
throw new Error('Failed to escalate fraud alert');
}
return { status: 'Escalation Triggered' };
};
4. Receptor: Handling Inbound Escalation Notifications
import { createReceptorAgent } from '@connectifi/sdk';
import { DesktopAgent, Context } from '@finos/fdc3';
interface EscalationAlert {
subject: string;
body: string;
severity: 'critical' | 'high' | 'medium' | 'low';
context: Context;
}
const sendEscalationAlert = async (alert: EscalationAlert) => {
const interopHost = 'https://platform.connectifi.app';
const token = '<YOUR_API_JWT>';
const from = 'compliance@example.com';
const agent = createReceptorAgent({ interopHost });
const alertData = {
channel: "complianceAlerts",
context: {
type: "fdc3.fraud.escalation.notification",
subject: alert.subject,
body: alert.body,
severity: alert.severity,
source: "Fraud Detection System",
context: alert.context,
}
};
// Broadcast the escalation alert to the compliance application
agent.broadcast(token, from, alertData);
};
Connectifi Platform Configuration
- Sign into the Connectifi Admin UI and navigate to your Directory.
- Register your Fraud Monitor Application, Compliance Application, and any other related services.
- Configure a Delivery Hook:
- Add the Delivery Hook handler (e.g., enrichFraudContextHook) to transform your suspicious transaction contexts.
- Create an Outbound Action:
- Setup the escalation action using your defined Data Action (e.g., escalateFraudAction) with the proper API endpoints.
- Define the Receptor configuration:
- Register the endpoint for your Compliance Application to receive escalation notifications.
- Validate the entire workflow using test contexts to ensure each component communicates as expected.
Next Steps
- Test the workflow by simulating suspicious transactions and verifying that the compliance team receives alerts.
- Explore additional context enrichment by integrating further risk factors.
- Leverage the Connectifi documentation and open source Connectors for deep dives into integrating Delivery Hooks, Actions, and Receptors.
- Consider extending the workflow by incorporating intent listeners for automated recovery or follow-up notifications.
This workflow offers a robust pattern for fraud detection and escalation using FDC3 and Connectifi, streamlining inter-application communication and ensuring rapid compliance response.