Routing Intents
A common scenario is an application that, upon a user’s request, needs to trigger a specific action (e.g., viewing a chart or processing a sales lead) across multiple Connectifi-enabled apps. In this workflow, the originating app raises an intent using the Connectifi Agent SDK, and the platform routes the intent to the appropriate recipient (which has registered an intent listener). This enables seamless inter-application communication while adhering to FDC3 standards.
Sequence Diagram
Components Description:
- End User Application (Agent SDK): Initiates the intent using methods like raiseIntent.
- Connectifi Routing Engine: Resolves the intent to the appropriate target by checking registered intent listeners.
- Target Application (Intent Listener): Has registered an addIntentListener for a specific intent and processes the context data accordingly.
Implementation Patterns & Code
Below are TypeScript examples illustrating how to raise an intent and register an intent handler.
Raising an Intent with the Agent SDK
import { DesktopAgent } from '@finos/fdc3';
import { createAgent } from "https://platform.connectifi.app/agent/main.bundle.js";
const initIntentWorkflow = async () => {
// Initialize the Connectifi Agent SDK
const agent: DesktopAgent = await createAgent('https://platform.connectifi.app', 'APP@DIRECTORY');
// Define the context to send with the intent
const salesContext = {
type: 'fdc3.sales.opportunity',
data: {
leadId: 'LEAD-123',
customerName: 'Acme Corp',
stage: 'Clarification'
}
};
// Raise an intent (e.g., "ViewSalesDetails")
try {
const response = await agent.raiseIntent('ViewSalesDetails', salesContext);
console.log('Intent processed with response:', response);
} catch (error) {
console.error('Error raising intent:', error);
}
};
initIntentWorkflow();
Registering an Intent Listener in the Target Application
import { createAgent } from "https://platform.connectifi.app/agent/main.bundle.js";
import { DesktopAgent } from '@finos/fdc3';
const initIntentListener = async () => {
// Create the Connectifi Agent for the application that will handle the intent
const agent: DesktopAgent = await createAgent('https://platform.connectifi.app', 'TARGET_APP@DIRECTORY');
// Register an intent listener for "ViewSalesDetails"
agent.addIntentListener('ViewSalesDetails', async (context) => {
console.log('Received intent with context:', context);
// Process the context data here (e.g., render sales details UI)
const processedResult = {
status: 'Processed',
details: { /* ... custom processing results ... */ }
};
// Return a result if needed
return processedResult;
});
};
initIntentListener();
Notes:
- The Raise Intent function triggers the Connectifi platform to search for an application that has an addIntentListener matching the intent name.
- The target app processes the intent and returns a response, which is then sent back along the same route.
Platform Configuration
To set up this workflow on the Connectifi platform, follow these high-level steps:
- Create or update your application registration in the Connectifi Admin UI (https://platform.connectifi.app/directories/create ).
- Ensure that your target application:
- Registers its intent listener (as shown above) for the desired intent.
- Is listed in the Connectifi directory with its correct metadata.
- For the originating application:
- Use the Connectifi Agent SDK to initialize the connection and properly raise intents.
- Optionally, configure logging and error handling (using patterns like the provided error recovery pattern) to monitor failed intent deliveries.
Next Steps
- Experiment with raising different types of intents (e.g., “ViewChart”, “ProcessOrder”) and verify the routed responses.
- Review the Connectifi documentation at https://docs.connectifi.co for additional integration examples and best practices.
- Explore further capabilities like Delivery Hooks for message transformation to enrich context data before resolution.
- Consider using the Connectifi Platform to manage administration aspects such as registering applications, intents, and configuring workflows.
By following these steps and utilizing the provided code samples, you can effectively raise and route FDC3 intents with Connectifi, improving your app’s interoperability in multi-application ecosystems.