Creating a Data Action
A Connectifi Data API Action is a mechanism within the Connectifi platform that enables your application to communicate with external services through standardized actions. In essence, it allows your app to act upon a particular FDC3 context by making outbound API calls, processing the data, and returning a result or updating the UI accordingly. This abstraction helps streamline integrations by using a consistent data action handler pattern that fits within the broader FDC3 and Connectifi ecosystem.
Below is an example of how you might implement a Data API Action using the Connectifi SDK:
import type { DataActionHandler } from '@connectifi/sdk';
import type { Context } from '@finos/fdc3';
const apiKey = process.env.SERVICE_API_KEY;
export const yourHandler: DataActionHandler = async (request) => {
const { context, intent } = request;
// Validate that a necessary API key is provided
if (!apiKey) {
throw new Error('Service API key is missing');
}
// Validate the intent against the ones your action supports
if (intent !== "expectedOne" && intent !== "expectedTwo") {
throw new Error("Intent not supported");
}
// Branch logic based on the request's intent
if (intent === "expectedOne") {
// Example: Call an external service with context details
const expectedOneResponse = await expectedOneService(apiKey, context.id.value);
return expectedOneResponse.details;
} else if (intent === "expectedTwo") {
const expectedTwoResponse = await expectedTwoService(apiKey, context);
return expectedTwoResponse;
}
};
Key Points About a Data API Action:
- It is a specialized handler (DataActionHandler) that takes a request—including both the FDC3 context and the intent name—and processes it.
- The handler typically validates the intent, manages any required authentication (such as checking for an API key), and makes outbound communication (e.g., REST API calls or deep link invocations) to external services.
- The result of the action is then passed back to the originator of the call, integrated seamlessly into the FDC3 workflow.
For further details on how these actions integrate with other parts of the Connectifi platform and FDC3 workflows, refer to our article on how to use Data Intents.
Data Actions enable you to create modular, maintainable integrations with external SaaS applications and ensure that your application remain scalable and maintainable through the flexibility of intent-based action triggers.