Build the Flow
Let's jump into Flow Builder and create a flow that uses the HTTP Callout element to request data. For this project, we've created a list of animals to use as the external data source.
Create a Flow
- Back in Setup, enter
flows
in Quick Find and select Flows.
- Click New Flow.
- Make sure Start from Scratch is selected, and click Next.
- Select Autolaunched Flow (No Trigger) and click Create.
Add an HTTP Callout Action
- Under Start, click .
- Select Action.
The Action configuration panel opens.
- In the configuration panel, click Create HTTP Callout.
The New HTTP Callout window opens. The first page creates the External Service.
- For Name, enter
AnimalsExternalService
.
- For Description, enter
External service to get animals from the Animals API
.
- For Named Credential, select Animals API Named.
The corresponding URL appears below Named Credential.
- Click Next.
On the next page, you configure the flow's invocable action.
- For Label, enter
GetAnimals
.
- For Method, select GET.
- For Description, enter
Get a list of animals from the Animals API
.
- For Set URL Path, enter
/animals
.
- Click Next.
Select a Sample Response Method
Here you select to make a connection to generate a real-time sample response or enter an example response so that the flow can structure the data returned from the external source.
- Select Connect for Schema.
- Click Next.
- For Description, enter
Get a list of animals from the Animals API
.
- Click Connect.
The Data Structure displays a structured data representation for your review. You should see an animals array (collection). Each item in the array is a string of characters (the name of the animal).
- Click Save.
Name the Action
- For Label, enter
Get Animals
.
The API Name is automatically set to Get_Animals.
- For Description, enter
Get a list of animals from the Animals API
.
Add an Assignment
- After the Get Animals action, click .
- Select Assignment.
- For Label, enter
Set Animals API Response
.
The API Name is automatically set to Set_Animals_API_Response.
- In Description, enter
Store the Animals API response in a variable
.
- Under Set Variable Values, for Variable, select New Resource.
- For Resource Type select Variable.
- For API Name, enter
AnimalsAPIResponse
.
- For Description, enter
Response value from the Animals API
.
- For Data Type, select Text.
- Select the Allow multiple values (collection) option.
- For Availability Outside the Flow, select Available for output.
- Click Done.
AnimalsAPIResponse should be displayed for Variable.
- Operator should be set to Equals.
- For Value, select Outputs from Get Animals, then 2 XX, then animals.
“Outputs from Get Animals > 2 XX > animals” appears in the field.
Save and Run the Flow
- Click Save.
- For Flow Label enter
Round Up the Animals
.
- For Description, enter
Get a list of animals from the Animals API
.
- Click Save.
You're ready to run the flow and see the results of your declarative excellence.
- Click Debug.
- Click Run.
- In the Debug Details pane, open the Assignment: Set Animals API Response to see the variable being set to the API response.
-
Activate the flow.
Congratulations! You used Flow Builder to create an HTTP callout that gets and returns data from an external source.
Feeling Inspired?
Now that you know the basics, you can have some fun with public APIs. Find something that interests you and repeat the process you followed in this project to access another external data source. You need to learn a bit about the API to determine exactly what information it needs from your HTTP callout. Then you can enter that information as another named credential and use it in a new flow.