External Services in Salesforce

by | Nov 29, 2022 | Salesforce, Salesforce Admin

Home » Salesforce » Salesforce Admin » External Services in Salesforce

Introduction

What if there’s a way to make API integrations in Salesforce without a single line of code? Make way for External Services!

As Admins, terms like API and Integration may seem daunting, but not anymore. Let’s find out why.

What are External Services?

External Services is a low code, Salesforce integration product that lets us connect to external web services and invoke methods based on the API scheme via a flow. It encompasses:

  • Registering an external web service.
  • We are bringing the operations of the external web service into Salesforce using point-and-click tools such as Flow Builder.

In short, we declaratively connect external REST APIs using OpenAPI standards.

Key Terms

1. External web services (external services)

This refers to any action, process or function developed and hosted outside the Salesforce platform. For an external service to be accessible by External Services, it should be a REST-based API.

(Keep in mind, this is different from the External Services we mentioned before.)

2. API specification (API spec)

This refers to a file that contains a descriptive schema that determines what an API can do. An API spec is readable by both machines and humans. It includes the definitions for naming, order, and contents of objects and ensures seamless interaction with a REST API. (External Services observe a JSON-based, OpenAPI specification format.

3. Invocable actions

This represents the declarative building blocks available on the Salesforce platform tools such as Flow Builder or Einstein Bots. It enables us, Admins and Developers, to implement and use actions consistently.

4. Flow Builder

It is the point-and-click tool on Salesforce that enables us to create flows.

5. Flow

A flow comes under the blanket term, Salesforce Flow, that enables us to perform actions or collect data in our Salesforce org or an external system.

Let’s understand the interconnected building blocks of External Services with the help of this block diagram:

A picture containing graphical user interface Description automatically generated

  1. The external web services provider hosts its REST-based API.
  2. The web service provider shares their JSON-based API spec.
  3. A Salesforce Admin/Dev declaratively (no code) creates a named credential to authenticate the web service endpoint with the URL of the REST-based API supplied by the external service provider.
  4. A Salesforce Admin can now declaratively register the web service using the API spec and Named Credential. (External Services will now import the API spec operations into your org and make them available as invocable actions.)
  5. A Salesforce Admin will now access the invocable actions using the Flow Builder.
  6. Run the flow. The flow can send a callout to the web service endpoint during runtime. The web service returns an output based on the API spec. The external web service can retrieve, create, update, or delete data.

External Services use-cases

  • Google Services
  • External Credit Service to verify an Account before extending credit
  • Digital payment services
  • Eligibility verification for discounts

API Specification for an External Service

1. Why do we require a Schema Definition?

Salesforce uses the commonly accepted OpenAPI specification for the description format of the structure of its REST-based APIs. Whether or not we create the API spec for our External Services registration, it’s crucial to know how it’s used and its purpose.

In simple words, a schema is a metadata. This is essential information for anyone wanting to interact with an API and its endpoints. API schemas provide machine-readable structured documentation that, together with regular documentation, make an API discoverable for developers.

Our API specs include a Schema Description, which defines the inputs and outputs we can have in the calls or requests that our org makes to the external web service.

Our API specs also include the endpoint information (this exposes the web service resources that the External Service interacts with) and authentication parameters for the REST-based API web services we can use.

Text, letter Description automatically generated

Here are some basic operations we can use in a schema description:

Table Description automatically generated

Here’s a snippet of a schema definition for a pet store obtained from Swagger.

curl -X 'PUT' \

'https://petstore3.swagger.io/api/v3/pet' \

-H 'accept: application/json' \

-H 'Content-Type: application/json' \

-d '{

"id": 10,

"name": "doggie",

"category": {

"id": 1,

"name": "Dogs"

},

"photoUrls": [

"string"

],

"tags": [

{

"id": 0,

"name": "string"

}

],

"status": "available"

}'

 

What Makes for a Valid and Supported Schema?

An External Service can adequately support our schema and call the web service only when the following two requirements are met:

  • OpenAPI schema validation requirements
  • External Services schema requirements

Here are a few points to keep in mind about schemas:

  • A schema must be machine-readable and human-readable.
  • It must have the proper logical structure.
  • It must adhere to structural, logical, and syntax restrictions.
  • Visit this link to view all the critical requirements for creating an External Services supported schema.

Register an External Service

1. Named Credentials and Endpoint Access

In addition to a valid API Spec, there are some other prerequisites to secure our external web service and Salesforce org. Let’s start by defining a Named Credential for our org.

Typically, the external web service provider would supply the elements for a Named Credential. And they include:

  • URL of a callout endpoint
  • Required authentication parameters

You might remember that API specs contain this information, and we’ll be using this information to define a Named Credential.

  1. From Setup, enter Named Credential in the Quick Find Box, and select Named Credentials.
  2. From the drop-down list next to New, click New Legacy.
  3. For Label, enter Banking.
  4. For URL, enter https://th-external-services.herokuapp.com
  5. Click Save.

2. Register Web Service Using External Services Wizard

  1. From Setup, enter External Services in the Quick Find Box, and select External Services.
  2. Click New External Service.
  3. Select From API Specification, and then click Next.
  4. Enter the following in Configure your External Service:
      • External Service Name: BankingService
      • Service Schema: Relative URL
      • Select a Named Credential: Banking
      • URL: /accounts/schema
  5. Click Save & Next.
  6. Select all Operations.
  7. Click Next.
  8. Click Done.

We just registered our first external service! There’s one more piece left in this puzzle. The Bank service’s account API operations are accessible within the Flow Builder. We can build flows that can be used to add a new bank account, update an existing one, and more! This is where the real power of External Services is harnessed.

Image Source

Author

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Author