Skip to main content
Build the future with Agentforce at TDX in San Francisco or on Salesforce+ on March 5–6. Register now.
Geschätzte Zeit

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

  1. Back in Setup, enter flows in Quick Find and select Flows.
  2. Click New Flow.
  3. Make sure Start from Scratch is selected, and click Next.
  4. Select Autolaunched Flow (No Trigger) and click Create.

Add an HTTP Callout Action

  1. Under Start, click Add Element.
  2. Select Action.
    The Action configuration panel opens.
  3. In the configuration panel, click Create HTTP Callout.
    In the Action configuration panel, the Create HTTP Callout button is below the list of categories.
    The New HTTP Callout window opens. The first page creates the External Service.
  4. For Name, enter AnimalsExternalService.
  5. For Description, enter External service to get animals from the Animals API.
  6. For Named Credential, select Animals API Named.
    The corresponding URL appears below Named Credential.
    New HTTP Callout window with Name, Description, and Name Credential set as described in the preceding steps 4, 5, and 6.
  7. Click Next.

On the next page, you configure the flow's invocable action.

  1. For Label, enter GetAnimals.
  2. For Method, select GET.
  3. For Description, enter Get a list of animals from the Animals API.
  4. For Set URL Path, enter /animals.
    New HTTP Callout window with Label, Method, Description, and URL Path set as stated in steps 8, 9, and 10 above.
Note

We want the entire list of animals, so we won't enter any query parameter keys. In another scenario, you might add

  1. 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.

  1. Select Connect for Schema.
    “”
  2. Click Next.
  3. For Description, enter Get a list of animals from the Animals API.
  4. 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).
  5. Click Save.

Name the Action

  1. For Label, enter Get Animals.
    The API Name is automatically set to Get_Animals.
  2. For Description, enter Get a list of animals from the Animals API.

Add an Assignment

  1. After the Get Animals action, click Add Element.
  2. Select Assignment.
  3. For Label, enter Set Animals API Response.
    The API Name is automatically set to Set_Animals_API_Response.
  4. In Description, enter Store the Animals API response in a variable.
  5. Under Set Variable Values, for Variable, select New Resource.
  6. For Resource Type select Variable.
  7. For API Name, enter AnimalsAPIResponse.
  8. For Description, enter Response value from the Animals API.
  9. For Data Type, select Text.
  10. Select the Allow multiple values (collection) option.
  11. For Availability Outside the Flow, select Available for output.
  12. Click Done.
    AnimalsAPIResponse should be displayed for Variable.
  13. Operator should be set to Equals.
  14. For Value, select Outputs from Get Animals, then 2 XX, then animals.
    “Outputs from Get Animals > 2 XX > animals” appears in the field.
    The Assignment configuration panel showing that the AnimalsAPIResponse variable equals Outputs from Get Animals > 2 XX > animals.

Save and Run the Flow

  1. Click Save.
  2. For Flow Label enter Round Up the Animals.
  3. For Description, enter Get a list of animals from the Animals API.
  4. Click Save.
    You're ready to run the flow and see the results of your declarative excellence.
  5. Click Debug.
  6. Click Run.
    The Debug Details pane shows the result of the assignment: a list of animals.
  7. In the Debug Details pane, open the Assignment: Set Animals API Response to see the variable being set to the API response.
  8. 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.

Teilen Sie Ihr Trailhead-Feedback über die Salesforce-Hilfe.

Wir würden uns sehr freuen, von Ihren Erfahrungen mit Trailhead zu hören: Sie können jetzt jederzeit über die Salesforce-Hilfe auf das neue Feedback-Formular zugreifen.

Weitere Infos Weiter zu "Feedback teilen"