Bonus Exercise 3.2: Use the Action in a Flow
Duration: 15 minutes
In this bonus exercise, we will add the Action to a scheduled Flow to keep our Airport information up to date on a regular basis.
- Close all the pop-up boxes and click on the + tab
- Click Flow
- Under Flow name, enter Update airport information
- Set Run As to System User
- Click Submit
- Click Add a trigger, then select Daily under date. This will run this workflow everyday
- Click Done
- Click Add an Action, Flow Logic, or Subflow
- Click Action
- Search and select Look Up Records - Pay special attention to selecting Look Up Records and not Look Up Record
- Search and select Airport under Table
- Click Done
- Click Add an Action, Flow Logic, or Subflow
- Click Flow Logic
- Click For Each
- Drag and drop the Airport Records data pill from the right sidebar onto the Items field
- Click the small + icon directly under the For Each Item in step
- Click Action
- Search and click Get Airport Details (this was the API integration action we just created)
- Expand Airport Record on the right sidebar under the 2 - For Each section
- Drag and drop the Code data pill onto the IATA Code field
- Click Done
- Add a new For Each Flow Logic under Get Airport Details
- Drag and drop the Output data pill from the 3 - Get Airport details section onto Items
- Click the small + icon directly under the new For Each Item in step
- Click Action, then search and select Update Record
- Drag and drop the Airport Record data pill under 2 - For Each onto the Record field
- Click + Add field value
- Search and select Lat, expand the response_object data pill under 4 - For Each
- Drag and drop the lat data pill on the empty field
- Click + Add field value
- Search and select Lon, expand the response_object data pill under 4 - For Each
- Drag and drop the lng data pill on the empty field
- Refer to the full animation below:
- Click Done
- Click Activate on the top right
- Click Test
- Click Run Test
- This will take a few minutes to run as we have 24 airports to update. Once done, click Your test has finished running. View the flow execution details.
- Review the execution, take some time to expand each step to understand what has happened in this flow
- Go back to App Engine Studio and preview the Airport table
- This will open in a new tab, verify that all the Lat and Lon fields are now populated
This flow should now run everyday to update the latitude and longitude of each airport in your table.
In a real life scenario, you could do so much more with the API, but this is just an example to show you the possibilites.
For example, you could integrate with a complex booking API like Amadeus, and your users could search for flights and book flights and hotels directly from your custom application!