integration-framework-design

Use when designing a reusable integration layer in Salesforce that serves multiple external APIs through a shared callout infrastructure. Triggers: 'how to design a reusable integration layer in Salesforce', 'architect an Apex callout framework for multiple APIs', 'create a centralized error handling pattern for integrations', 'service interface pattern for external APIs', 'factory pattern for dynamic API resolution', 'centralized callout dispatcher'. NOT for individual API implementation (use apex/callouts-and-http-integrations), NOT for Named Credential setup (use integration/named-credentials-setup), NOT for async callout patterns (use apex/continuation-callouts).

Best use case

integration-framework-design is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Use when designing a reusable integration layer in Salesforce that serves multiple external APIs through a shared callout infrastructure. Triggers: 'how to design a reusable integration layer in Salesforce', 'architect an Apex callout framework for multiple APIs', 'create a centralized error handling pattern for integrations', 'service interface pattern for external APIs', 'factory pattern for dynamic API resolution', 'centralized callout dispatcher'. NOT for individual API implementation (use apex/callouts-and-http-integrations), NOT for Named Credential setup (use integration/named-credentials-setup), NOT for async callout patterns (use apex/continuation-callouts).

Teams using integration-framework-design should expect a more consistent output, faster repeated execution, less prompt rewriting, better workflow continuity with your supporting tools.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.
  • You already have the supporting tools or dependencies needed by this skill.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/integration-framework-design/SKILL.md --create-dirs "https://raw.githubusercontent.com/PranavNagrecha/AwesomeSalesforceSkills/main/skills/architect/integration-framework-design/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/integration-framework-design/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How integration-framework-design Compares

Feature / Agentintegration-framework-designStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Use when designing a reusable integration layer in Salesforce that serves multiple external APIs through a shared callout infrastructure. Triggers: 'how to design a reusable integration layer in Salesforce', 'architect an Apex callout framework for multiple APIs', 'create a centralized error handling pattern for integrations', 'service interface pattern for external APIs', 'factory pattern for dynamic API resolution', 'centralized callout dispatcher'. NOT for individual API implementation (use apex/callouts-and-http-integrations), NOT for Named Credential setup (use integration/named-credentials-setup), NOT for async callout patterns (use apex/continuation-callouts).

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

Use this skill when you are building or reviewing an integration layer that must serve more than one external API without duplicating HTTP mechanics, auth handling, logging, or retry logic across multiple callout classes. The goal is a framework that is cohesive, observable, and reconfigurable without code changes.

## Before Starting

- How many external APIs does this framework need to serve now and in the near future?
- Which callout requirements are shared (auth, retry, logging, timeout) versus API-specific (payload shape, error mapping)?
- What are the observability requirements — do integration logs need to be queryable by support teams?
- Is there a need for environment-specific endpoints (sandbox vs production) managed without code changes?
- What is the retry budget — synchronous retry on transient failure, or async dead-letter queue for durable retry?

## Core Concepts

### Service Interface Pattern

Define a single Apex interface that every external API adapter must implement. The interface declares the contract — a `callout()` method and a `parseResponse()` method — without prescribing how any particular API fulfills it. Callers depend only on the interface, not on any concrete implementation.

```apex
public interface IIntegrationService {
    HttpResponse callout(IntegrationRequest request);
    IntegrationResult parseResponse(HttpResponse response);
}
```

Each API gets its own concrete class implementing `IIntegrationService`. The class knows the API's payload structure, authentication mechanism, and response mapping. Nothing else in the org needs to know those details.

### Factory Pattern with Custom Metadata

Hard-coding which service class to instantiate in calling code creates coupling that breaks as the integration landscape grows. Use a factory class that reads from a Custom Metadata Type (`Integration_Service__mdt`) to resolve the right implementation at runtime.

```apex
public class IntegrationServiceFactory {
    public static IIntegrationService resolve(String serviceApiName) {
        Integration_Service__mdt record = [
            SELECT Service_Class__c, Endpoint__c, Active__c
            FROM Integration_Service__mdt
            WHERE DeveloperName = :serviceApiName
            AND Active__c = true
            LIMIT 1
        ];
        Type serviceType = Type.forName(record.Service_Class__c);
        return (IIntegrationService) serviceType.newInstance();
    }
}
```

`Integration_Service__mdt` fields: `DeveloperName` (API name key), `Service_Class__c` (fully-qualified Apex class name), `Endpoint__c` (base URL), `Active__c` (toggle), `Timeout_Ms__c` (per-service override).

This design allows endpoint swapping across environments without touching Apex. It also allows deactivating a service in emergency without a deployment.

### Centralized Callout Dispatcher

The dispatcher is the single class that wraps `HttpRequest` / `HttpResponse` mechanics. It handles authentication header injection (via Named Credentials or stored secrets), timeout configuration, retry on transient status codes (429, 503), correlation ID generation, and response logging. Concrete service classes do not create `Http` instances directly — they delegate to the dispatcher.

```apex
public class HttpCalloutDispatcher {
    public HttpResponse dispatch(HttpRequest req, String correlationId) {
        Http http = new Http();
        Long start = System.currentTimeMillis();
        HttpResponse res;
        try {
            res = http.send(req);
        } catch (System.CalloutException e) {
            IntegrationLogger.logFailure(req, e, correlationId);
            throw new IntegrationException(IntegrationException.ErrorCode.CALLOUT_FAILURE, e.getMessage());
        } finally {
            IntegrationLogger.logResponse(req, res, start, correlationId);
        }
        return res;
    }
}
```

### Request and Response DTOs

Strongly-typed request and response objects prevent primitive obsession. `IntegrationRequest` carries endpoint, method, headers, and body. `IntegrationResult` carries success flag, parsed payload, HTTP status, error code, and correlation ID. These shapes are stable across all concrete services — only the body contents differ.

### Response Logging

Every callout, successful or failed, writes an `IntegrationLog__c` record. Fields: `Endpoint__c`, `HTTP_Method__c`, `Status_Code__c`, `Request_Body__c` (truncated at 131,072 chars), `Response_Body__c` (truncated), `Duration_Ms__c`, `Correlation_ID__c`, `Success__c`, `Error_Message__c`, `Service_Name__c`, `Created_By_Context__c` (trigger, batch, queueable).

Logging synchronously from within a callout is safe in non-trigger contexts. In trigger context, use Platform Events to decouple logging DML from the transaction — see gotchas.

### Error Propagation

Define a typed exception class with an inner error code enum so callers can branch on failure type without string parsing.

```apex
public class IntegrationException extends Exception {
    public enum ErrorCode {
        CALLOUT_FAILURE,
        AUTH_FAILURE,
        TIMEOUT,
        RATE_LIMITED,
        PARSE_FAILURE,
        SERVICE_DISABLED
    }
    public ErrorCode code { get; private set; }
    public IntegrationException(ErrorCode code, String message) {
        this(message);
        this.code = code;
    }
}
```

For async contexts, implement a dead-letter pattern: failed callout requests are written to a `Dead_Letter_Queue__c` custom object or Platform Event topic for retry by a scheduled Queueable that respects a configurable retry budget.

### Dynamic Service Resolution

The `Integration_Service__mdt` Custom Metadata Type acts as a service registry. Because Custom Metadata records are queryable in tests without DML and are deployable as metadata, they travel through CI/CD pipelines alongside code. Per-environment endpoint overrides can use org-specific Custom Metadata record overrides or Named Credentials (preferred for credentials).

## Recommended Workflow

1. **Inventory integrations** — list all external APIs, their protocols, auth mechanisms, and retry requirements. Identify which callout behaviors are shared versus unique.
2. **Design the interface and DTOs** — define `IIntegrationService`, `IntegrationRequest`, and `IntegrationResult` before writing any concrete adapter. Lock the contract first.
3. **Create the Custom Metadata Type** — create `Integration_Service__mdt` with the required fields. Add one record per external API. This is the service registry.
4. **Build the dispatcher** — implement `HttpCalloutDispatcher` with auth injection, timeout, retry logic, correlation ID, and call to `IntegrationLogger`.
5. **Implement concrete service adapters** — one class per API implementing `IIntegrationService`. Each class knows only its API's payload and error mapping. It calls the dispatcher for HTTP.
6. **Implement `IntegrationServiceFactory`** — use `Type.forName()` to resolve service classes from Custom Metadata. Add `null`/`inactive` guard and surface `SERVICE_DISABLED` error code.
7. **Validate and test** — mock the dispatcher in unit tests using an interface split. Run validate_repo after scaffolding. Confirm `IntegrationLog__c` records are created in integration tests.

## Related Skills

- `apex/callouts-and-http-integrations` — use for individual HttpRequest/HttpResponse implementation details and Named Credential usage
- `apex/apex-design-patterns` — use for service layer, selector, and dependency injection patterns that complement this framework
- `apex/custom-metadata-in-apex` — use for CMDT query patterns, test data setup, and deployment considerations
- `integration/named-credentials-setup` — use when designing the auth layer of the dispatcher
- `apex/exception-handling` — use when designing the exception hierarchy and propagation strategy

Related Skills

scim-provisioning-integration

8
from PranavNagrecha/AwesomeSalesforceSkills

Use when designing or reviewing SCIM-based user lifecycle provisioning into Salesforce from Okta, Azure AD / Entra, or another IdP — create/update/deactivate, group-to-permission-set mapping, attribute mapping, and deprovisioning semantics. Triggers: 'scim provisioning', 'okta scim salesforce', 'entra salesforce provisioning', 'user deactivation automation', 'group to permission set mapping'. NOT for SSO/authentication setup (see single-sign-on skills).

omnistudio-lwc-integration

8
from PranavNagrecha/AwesomeSalesforceSkills

Use when embedding OmniScripts in Lightning Web Components, registering custom LWC elements inside OmniScript screens, or calling OmniScript/Integration Procedures from LWC. Triggers: embed omniscript in LWC, custom LWC element in OmniScript, call OmniScript from Lightning page, omnistudio-omni-script tag, seed data JSON, OmniScript launch from LWC. NOT for standalone LWC development, standard Flow embedding, or OmniScript-to-OmniScript embedding.

omniscript-design-patterns

8
from PranavNagrecha/AwesomeSalesforceSkills

Use when designing or reviewing OmniScripts for guided experiences, step structure, branching, save/resume, and the boundary between OmniScript, Integration Procedures, DataRaptors, and custom LWCs. Triggers: 'omniscript design', 'too many steps in omniscript', 'save and resume omniscript', 'branching in omniscript', 'when should this be an integration procedure'. NOT for deep Integration Procedure or DataRaptor design when the guided interaction layer is not the main concern.

integration-procedures

8
from PranavNagrecha/AwesomeSalesforceSkills

Use when building, reviewing, or debugging OmniStudio Integration Procedures. Triggers: 'integration procedure', 'IP', 'HTTP action', 'DataRaptor', 'rollbackOnError', 'failureResponse'. NOT for Apex-only integrations unless the main design choice is whether OmniStudio is still appropriate.

integration-procedure-cacheable-patterns

8
from PranavNagrecha/AwesomeSalesforceSkills

Use when designing Integration Procedures (IPs) with platform cache to cut latency and callout load. Covers cache key design, TTL selection, per-user vs org-wide partitions, invalidation on data changes, and safe fallback on cache miss/stale. Does NOT cover general IP authoring (see omnistudio-error-handling-patterns) or LWC client-side caching.

flexcard-design-patterns

8
from PranavNagrecha/AwesomeSalesforceSkills

Use when designing, building, or reviewing OmniStudio FlexCards — including data source selection, card states, actions, conditional visibility, flyout configuration, and child card iteration. Triggers: 'FlexCard', 'card template', 'flyout', 'card action', 'card state', 'data source', 'child card', 'conditional visibility'. NOT for OmniScript design, standalone LWC development, or Apex controller architecture outside the FlexCard context.

calculation-procedure-design

8
from PranavNagrecha/AwesomeSalesforceSkills

Design OmniStudio Calculation Procedures and Calculation Matrices for pricing, rating, and rules-heavy scoring. Trigger keywords: calculation procedure, calculation matrix, rating engine, pricing matrix, expression set, decision matrix, OmniStudio rules. Does NOT cover: generic Apex-only pricing code, Salesforce CPQ price rules (different product), or Flow-based decision logic.

slack-salesforce-integration-setup

8
from PranavNagrecha/AwesomeSalesforceSkills

Use this skill when setting up or troubleshooting the Salesforce for Slack managed app — including connecting a Salesforce org to a Slack workspace, configuring the three-party admin handshake, linking Slack channels to Salesforce records, enabling record preview sharing, and managing org-level limits. Triggers on: Salesforce for Slack app not connecting, Slack org connection setup, Salesforce record sharing in Slack, Slack workspace admin approval, connecting Salesforce to Slack. NOT for building custom Slack apps or Slack bots (separate development platform), not for Slack Workflow Builder Salesforce connector (use slack-workflow-builder skill), not for Flow-based Slack messaging (use flow-for-slack skill).

sis-integration-patterns

8
from PranavNagrecha/AwesomeSalesforceSkills

Use this skill when designing or implementing an integration between a Student Information System (SIS) — such as Ellucian Banner, Ellucian Colleague, Anthology Student, Oracle PeopleSoft Campus Solutions, or Workday Student — and Salesforce Education Cloud. Covers the canonical Education Cloud data model objects (AcademicTermEnrollment, CourseOfferingParticipant, CourseOfferingPtcpResult, LearnerProfile, PersonAcademicCredential), external ID / upsert keying strategies using SIS-native identifiers (Banner PIDM, PeopleSoft EMPLID), batch nightly upsert patterns, Change Data Capture (CDC) for enrollment status writeback, and MuleSoft/middleware watermark patterns. Trigger keywords: SIS integration, Banner integration, PeopleSoft integration, Education Cloud data model, enrollment sync, grade writeback, AcademicTermEnrollment, LearnerProfile upsert. NOT for Salesforce Admissions Connect application processing, Financial Aid integration, Learning Management System (LMS) integrations, or general ETL tooling not involving Education Cloud objects.

salesforce-to-salesforce-integration

8
from PranavNagrecha/AwesomeSalesforceSkills

Use this skill to implement Salesforce-to-Salesforce integration patterns — covering the native S2S feature, API-based cross-org sync, Platform Event bridging, and Salesforce Connect Cross-Org adapter. Trigger keywords: Salesforce to Salesforce integration, cross-org data sharing, S2S feature, cross-org Platform Events, Salesforce Connect cross-org. NOT for multi-org strategy or architecture decisions (use architect/multi-org-strategy), single-org data sharing, or external (non-Salesforce) system integration.

real-time-vs-batch-integration

8
from PranavNagrecha/AwesomeSalesforceSkills

When to use this skill: choosing between real-time (synchronous callouts, Platform Events, CDC, Pub/Sub API) and batch (Bulk API 2.0, scheduled ETL) integration patterns. Trigger keywords: should I use real-time or batch, how to sync high-volume data, when to use Platform Events vs Bulk API, integration latency vs volume tradeoff. NOT for Batch Apex internals (use batch-apex-patterns), NOT for MuleSoft middleware design (use middleware-integration-patterns), NOT for CDC field tracking configuration.

platform-events-integration

8
from PranavNagrecha/AwesomeSalesforceSkills

Use when publishing Platform Events from external systems via REST API, subscribing to Platform Events from outside Salesforce via CometD or Pub/Sub API, designing replay ID strategy for durable external consumers, or handling high-volume event delivery guarantees. Trigger keywords: 'external publish platform event', 'CometD subscribe', 'Pub/Sub API', 'replay ID external', 'durable subscription', 'RetainUntilDate'. NOT for Apex-only event publishing or triggering (use platform-events-apex). NOT for Change Data Capture external subscription (use change-data-capture-integration).