Skip to Content
The BasicsHandling Data Intents

Handling Data Intents

• First, create and initialize your Connectifi Agent using the Connectifi Agent SDK.
• Then, raise the intent by calling agent.raiseIntent with the intent name and a context.
• Once the intent is handled, await the result using getResult(), and finally, render the returned data (for example, by updating your UI).

Below is a TypeScript code example that demonstrates these steps:

import { DesktopAgent } from '@finos/fdc3'; import { createAgent } from "https://platform.connectifi.app/agent/main.bundle.js"; // Function to render the response data to the UI function renderResponse(data: any): void { // Implement your rendering logic here; for example, updating the DOM or state console.log("Rendered Response:", data); } // Immediately Invoked Async Function to initialize and raise intent (async () => { // Create the Agent instance from Connectifi Platform const agent: DesktopAgent = await createAgent('https://platform.connectifi.app', 'APP@DIRECTORY'); // Define your context to be passed with the intent. Ensure it matches your application's data schema. const contextData = { type: 'fdc3.example.context', data: { id: "12345", name: "Sample Data" } }; try { // Raise the intent; for instance, "YourCustomIntent" should correspond to an intent configured in your Connectifi Platform const intentResult = await agent.raiseIntent('YourCustomIntent', contextData); // Await the result from the intent handler const resultData = await intentResult.getResult(); // Render the response data renderResponse(resultData); } catch (error) { console.error("Error while raising the intent:", error); } })();

This pattern encapsulates Connectifi’s approach to inter-application communication using FDC3 APIs and ensuring that workflows can easily trigger and render responses from intents.

Last updated on