By Bryan Barrows
Okta Workflows includes an ever-growing library of connectable applications with pre-built actions and events that allow you to quickly automate business processes with ease.
However, there are times when we might know that an API that we’re leveraging has a different endpoint or some other method by which we could extract additional necessary information.
These situations are what the Custom API Action cards included with each app connector are made for.
In this example, I’ve leveraged Slack – Custom API Cards to retrieve the full user profile as well as their status (active/away).
These details aren’t available in the default Slack - Read User
card, but by leveraging the Custom API Action, we’re able to take advantage of more of the functionality of Slack’s API.
To accomplish this, we’ll reference Slack’s API docs to learn more about the /users.info and /users.getPresence methods.
A simple GET
to those Relative URLs should do the trick…
- Use a
Slack - Read User
get the Slack User ID. - Use an
Object - Construct
with a key ofuser
and input the Slack ID from the previous step. We’ll use this query object in both of our Slack – Custom API cards to specify which user we want information about. - Use two
Slack - Custom API
cards with a method ofGET
and the following Relative URLs:
/users.info
/users.getPresence
- Drag the object output from Step 2 into the "Query" input of each Custom API card.
And that’s all there is to it! Looks like it worked:
Now you can use a pair of Object – Get Multiple cards to parse whatever data you need out of each response body.
Notes
- I’ve used
Okta - User Added to Group
for sake of example. You can substitute this to meet your needs. Just make sure to use theSlack - Read User
to get the Slack User ID needed for the query object. - If you zoom in on my flow, you’ll also notice that I built some error handling into my flow by putting my Custom API calls within an "If Error" card and building outputs in the case of a success as well as a failure. It’s never a bad idea to build some error handling into your flows to make them more robust.
Feel free to download this example and import it to your environment.
Download steps:
- right click "view raw"
- click "Save Link As"
- be sure the filename ends in
.flow
!
Read more about how to import and export flows here.
Hope this helps! Find me on LinkedIn or join us at a Community Office Hours session if you have any questions or want to chat about what you’re working on – would love to see you there!