Using Flow to Make an HTTP Callout without Code

Using Flow to Make an HTTP Callout without Code

Flow is the most powerful automation tool of Salesforce and it gives the admins the powers of developers. It is possible to manipulate data in a variety of ways, schedule the automations, build screens to display or get an input from the users, and so on. If you have been working with Salesforce for many years, you probably see the importance of Flow. Years ago, there was only Workflow Rules and anything beyond updating records was a dream for the admins. After adding continuous enhancements, Flow has become Salesforce's most popular automation tool and the best friend of admins. Moreover, with the new Flow features of the Spring '23 release, Salesforce convinced us that Flow is really giving admins the powers of developers. Now you can make an HTTP Callout from Flow without any code!

HTTP Callout (Beta)

Using the new HTTP Callout (Beta) button from the action element, you can now make calls to external web services.

HTTP Callout Button

It is a new beta feature that Salesforce introduced in the Spring '23 release. Although it supports GET calls only (for now), it is a very useful feature. Before this release, you had to build Apex classes in order to make calls to external web services. Now you can make an HTTP callout directly from Flow without using any code. This is a game changer!

This feature is available in any Flow type that contains the action element. For instance, you can build a record-triggered flow to make an HTTP callout when a record meets a criteria.

Let's build a Screen Flow that makes an HTTP callout to bring the current exchange rates for USD.

HTTP Callout to Get Exchange Rates

There are many great APIs that you can find online. In this example, let's use Abstract API's Exchange Rates API.

1- According to their API documentation, the request should be like this:

https://exchange-rates.abstractapi.com/v1/live?api_key=YOUR_UNIQUE_API_KEY&base=USD&target=EUR,CAD

First of all, let's create a Named Credential in Salesforce. Go to setup, search for Named Credentials and click New Legacy. Enter a name for the Named Credential and enter this for the URL:
https://exchange-rates.abstractapi.com/v1/live/
Then make the configurations like this:

Named Credential

2- Create a Screen Flow, add an Action element and hit the Create HTTP Callout (Beta) button.
The first screen is for creating an external service. Enter a name and select the named credential that you created. Click Next to go to the second screen.

New HTTP Callout

3- This screen is for creating an invocable action. Give it a name and select the method (only GET option is available for now).

Create Invocable Action

According to the API documentation, you need to pass the API key, base, and target parameters. First two parameters are required. Click Add Key to create the query parameter keys and select their data types.

Add Query Parameter Keys

After adding the query parameter keys, you have to provide a sample API response body. Click New and paste a sample API response body. You can find the sample from the API documentation.

Provide Sample Response

After pasting a JSON-formatted sample API response body, click Review. This will create the data structure.

Sample Response

Click Done to finish creating the invocable action.

4- Provide values for the query parameter keys that you created in the previous step. For example, let's get the exchange rates for Euro and Shekel.

Action to Make HTTP Callout

5- Response of the HTTP callout is saved in an Apex defined variable called 2XX. Add a Screen element and display the Euro and Shekel exchange rates on the screen.

Display the Response of the Callout

At the end, your flow should look like this.

End of the Flow

Let's debug the flow. As you can see, current exchange rates are displayed on the screen.

Result of the HTTP Callout

Automatically Update the Exchange Rates In Multi-Currency Organizations

In the previous example, you saw how to display the response on the screen. If you are using multiple currencies, you can create a schedule-triggered flow that runs every day and updates the exchange rates in the setup. This is truly a game changer!

Create a schedule-triggered flow that runs every day and follow the steps above (except for the screen). Then add an Update Records element to update the ConversionRate field of the Currency Type.

Update ConversionRate of Euro

Here is the EUR_Rate formula resource.

Euro Rate Formula

If you want to use this action in a schedule-triggered flow, add a pause element to wait before calling the action. Otherwise, you might get this error:

"Callout failed for invocable action ExchangeRatesAPI.ExchangeRatesAPI. Can't perform callout when resuming a flow or inside an Apex Queueable. Place the callout to External Services invocable actions before pausing a flow or scheduling an Apex queueable. For more information, contact your Salesforce administrator."

At the end, your flow should look like this:

Schedule-triggered flow to update the exchange rates

As you can see, it updated the Conversion Rate of Euro.

Conversion Rate of Euro

Other Examples

There are endless use cases for the HTTP callout feature. Let's see a few more examples.

Here is a callout to convert Gregorian date to Hebrew date. This is a public API of Hebcal and you just need to pass the Gregorian date and it returns the Hebrew date.

Convert Gregorian date to Hebrew date

Here is another example to validate an email address using the Email Validation API of Abstract API.

Email Validation

Actually, this one is very useful. You can create a REGEX validation rule to prevent entering emails in wrong formats. However, you cannot know if the email address is real or not. For instance, a validation rule cannot catch that this is a fake email address: [email protected]

Using this API, you can check the deliverability of the email addresses and block saving fake data.

Summary

HTTP Callout is probably the most important Flow feature of the Spring '23 release. Although it supports only GET calls (for now), there are endless use cases. This feature is really a game changer and I am personally very excited to see the future of Flow. After this point, I think it is safe to say that Flow really gives the admins the powers of developers!

8 Comments

    • Hi,
      Do you have the Spring '23 Release in your org? It is a new feature of this release.
      If you don't have it, just wait a few more days until you get the release.

  1. Hi,
    How would I do it having to authenticate first with client and secret id and then call the service passing a custom header with authorization, please?
    Thanks

6 Trackbacks / Pingbacks

  1. Avoid Callout Errors in Screen Flows Automatically - Salesforce Time
  2. New Flow Features of Summer '23 Release - Salesforce Time
  3. FlowFest V5 Challenges - Challenge 2 - Salesforce Time
  4. New Flow Features of Winter '24 Release - Salesforce Time
  5. Using Flow to Integrate ChatGPT with Salesforce - Salesforce Time
  6. How and When to Use Loop in Salesforce Flow - Salesforce Time

Leave a Reply

Your email address will not be published.


*