In today’s interconnected digital landscape, businesses depend on a diverse range of applications and systems to efficiently manage their operations, making seamless integration imperative. Salesforce, a pioneer in cloud-based CRM solutions, provides an impactful integration tool called External Services. Harnessing the OpenAPI 3.0 standard, External Services empowers organizations to integrate systems seamlessly with their Salesforce environment.
What is External Services?
External Services is a cutting-edge integration solution offered within Salesforce. It enables organizations to seamlessly incorporate external web services into their Salesforce environment by leveraging the OpenAPI (previously known as Swagger) specification, which precisely defines the web service. This integration empowers users to seamlessly bring the functionalities of their external web service into the robust Salesforce platform, utilizing intuitive point-and-click tools such as flow builder.
As the picture depicts, the OpenAPI specification connects different types of APIs with Salesforce using External Services.
Key features and benefits
Standardized integration: With OpenAPI, External Services promotes standardization and interoperability, allowing seamless integration with a wide range of external systems and services.
Simplified configuration: External Services offers an intuitive interface for configuring and consuming external APIs. Users can import OpenAPI specifications directly into Salesforce and map API resources to custom objects, making integration setup a breeze.
Enhanced flexibility: By leveraging OpenAPI, External Services supports advanced features such as data validation, schema referencing, and parameterized requests, providing greater flexibility and control over integration workflows.
Streamlined development: External Services accelerates integration development by generating Apex code stubs based on imported OpenAPI specifications called dynamic classes. This automates much of the coding process, reducing development time and effort.
Before we discuss External Services in depth, let’s understand the OpenAPI specification and how it helps with the integration of external systems.
Understanding OpenAPI
OpenAPI, is a specification for building APIs. It provides a standardized way to describe RESTful APIs, which makes it easier for developers to understand and interact with APIs.
- Defines a standard, language-agnostic interface to HTTP APIs.
- Enables humans and computers both to discover and understand the service’s capabilities without access to source code, documentation, or through network traffic inspection.
As seen in the above diagram, seven different components constitute OpenAPI specification (currently, OpenAPI 3.0 is taken as reference). The following components represent any REST-based API covering all web service aspects: endpoints, request/response formats, and security definitions.
External Service Setup
We need to configure the following three entities to consume any REST-based API to start making callouts.
1. Setup named credentials:
For any REST API callouts, we need integration user details to connect with external systems, such as username/password as part of the basic authentication model, client ID/client secret as part of the OAuth authentication model, etc. All these details will be stored in the named credentials entity.
Therefore, named credentials in Salesforce provide a secure and easy way to authenticate external services within your Salesforce org. They abstract the endpoint URL and authentication details, making integrations more secure and manageable.
Named credentials define the URL of a callout endpoint as well as its required authentication parameters in a single definition. To put it simply, the setup of authenticated callouts defines a named credential as the callout endpoint.
2. Register External Service:
In the first step, “Setting up named credentials,” the system allows us to manage the authentication details needed for making callouts. Now, we need to register the service in External Service. All it takes is selecting named credentials and importing the OpenAPI specification into the External Service configuration wizard, which will automatically generate the stub classes. All these auto-generated classes get stored under dynamic classes in the Apex Classes section.
An OpenAPI spec can have a whole set of APIs as part of the module, and external service enables us to consume all the APIs in one go. While registering, the wizard takes us to a screen where we can only enable the required services.
3. Create a flow/apex component to make callouts
With the named credentials and external service defined, we start making calls to web services using Flow or Apex.
- Flow:As soon as an external service is defined, the system creates an action for the flow under the External Service section, which can be used to select the API/Operation we want to do.
- Apex:After registering the external service, we can call it natively in your Apex code. Objects and operations defined in the external service’s registered API specification become Apex classes and methods in the ExternalService namespace.
Conclusion
Powered by the OpenAPI 3.0 standard, Salesforce’s External Services revolutionizes how organizations integrate external systems with their CRM platform. External Services enables businesses to unlock new opportunities for innovation, efficiency, and growth by providing a standardized, flexible, and efficient approach to integration. Whether integrating payment gateways, marketing automation platforms, ERP systems, or any other external services, External Services with OpenAPI empowers organizations to streamline processes, enhance collaboration, and deliver exceptional customer experiences. With External Services, the possibilities for integration are endless, paving the way for a more connected and agile digital ecosystem.