HTTP GET callout example using Flow

In this blog we are going to explore practical example of making the HTTP GET callout using Salesforce Flow.

Salesforce introduced a new feature that empowers us to perform HTTP GET callouts using Flows from summer’23 release.

Salesforce utilizes HTTP callouts to interact with external systems and APIs through the HTTP protocol, enabling user to send requests and receive responses from external endpoints.

Configure Permissions

To enable HTTP callouts using Salesforce Flow, it is essential to configure the permission sets in our Salesforce org.

This permission set empowers the user to perform callouts seamlessly using Salesforce Flow.

Permission set for HTTP Get callout using Salesforce Flow

To create a new permission set and add your user to it, follow these steps:

  1. Click on the ⚙ gear icon and and navigate to permission sets.
  2. Create a new permission set.
  3. Click the “Manage Assignments” button and assign your user to the newly created permission set.

Permission Set Assignment

Now we need to create a named credential and external credential.

A Named credential serves as a secure storage for authentication information related to an external service or endpoint.

It allows for easy access and retrieval of essential authentication details, including username, password, or OAuth token.

In this blog post we are going to make a callout to the Joke API which will give us some random jokes in the output.

As you are aware, the external credential is a compulsory field during the creation of a Named Credential.

First, we will create the external credential and then proceed with the creation of the Named credential.

External Credentials

To ensure data security between Salesforce and external systems, a reliable authentication protocol is implemented, establishing a secure connection.

This fortified connection guarantees confidential data exchange, safeguarded against unauthorized access.

When configuring external credentials, there are three authentication protocol options available:

    1. OAuth 2.0
    2. AWS Signature Version 4
    3. Custom

If the API doesn’t require a client and secret key, the Custom authentication protocol can be used.

For APIs that require a client and secret key, either OAuth 2.0 or AWS Signature Version 4 should be selected as the authentication protocol.

AWS Signature Version 4 is used to authenticate callouts to Amazon Web Services resources over HTTP, with the identity type as Named Principal.

Check out more Summer’23 release Salesforce Flow features and enhancements here

OAuth uses an authentication provider to issue a token to Salesforce after user login via a browser, granting access for callouts to the endpoint.

For this example, since we are communicating with a publicly available API, a custom authentication protocol will be used.

Joke external credential http get callout

Once the external credential is created, we will create the principal record.

Joke API Principal record HTTP get callout example

By passing this principal record to our pre-existing permission set, we can authorize it to recognize the named credential.

Named Credential

Now we will create the Named credential.

In the URL field, we will add the URL to the Joke API of appspot.com

Named Credential

Create the Flow

We have completed the prerequisites for making the HTTP GET callout using Flow. Let’s proceed by going to the Flow Builder and crafting a Screen Flow.

Firstly, we will add a screen element to the Flow and prompt the user to choose whether they want a single joke or multiple jokes to be generated.

Number of Jokes to be generated

Now, let’s add a decision element to the flow to check whether the user wants to generate a single joke or multiple jokes.

Joke Selection by Users

Based on the number of jokes the user wants to generate, we will take the appropriate action.

Want to Learn Salesforce Flows? Checkout our Salesforce Flow Course

Configuring HTTP Callout

Navigate to the Action element and click Create HTTP Callout button.

HTTP Callout Button

Provide the external service name and select the named credential.

Selected Named Credentials

Click next and now you should provide the invocable action and select the GET method. Pass “/random_joke” in the URL path field.

HTTP callout Invocable action

In the Provide Sample Response section click on New and pass the response you get by hitting the API.

Paste the response in the Sample JSON Response section.

API Callout response

It’s essential to note that since this API generates random jokes, the callout will produce different output for each user.

JSON Response

Click on Done and save the new action by providing its label name.

Get a Joke

Now we will add a screen element to display the joke to the user generated by the API callout.

Joke output screen

You can observe that the API callout generates a single joke. Now, let’s set up the HTTP callout action to generate multiple jokes through a GET request.

Generating Multiple jokes using HTTP GET callout

Please give the name of the external service and choose the “Joke named credential”.

Multiple Jokes External Services

Click next and provide the invocable action and select the GET method. Pass “/random_ten” in the URL path field.

Click on New in the “Provide Sample Response” section,  Afterward, paste the API callout response into the “Sample JSON Response” section.

API Response for Multiple Joke

To display these multiple jokes, we’ll utilize a Loop element since they constitute a collection of jokes.

Multiple Jokes loop element

Introduce a screen element that showcases the multiple user-generated joke from the API callout

Multiple Jokes Output

Debug the Flow. If you choose ‘Multiple’ from the picklist, the API callout will generate multiple jokes.

Business use cases for initiating HTTP callouts using Salesforce Flow

  • The retail company wants to showcase its real-time product inventory to customers to make their shopping experience seamless.
  • The marketing team needs to analyze social media trends and how people feel about their brand.
  • An event management firm wants to get weather updates for upcoming events and update event records accordingly.

For video tutorial

Get a complete Roadmap To Learn Salesforce Admin And Development 👇

Share Now

Harshit is a 5x certified Salesforce developer currently working at UST. He is a storyteller at heart, with a knack for crafting compelling content on LinkedIn and penning insightful blogs on Salesforce technology.

Similar Posts

Leave a Reply

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