Parse Example

This example shows how to get the status of a Slack user from the user's Slack profile. This information is useful to have when the user is out of the office or have their status set to a custom status. It also shows how to perform JSON parsing and how to get values from a JSON string.

Three cards are used in this flow:

  • Slack Read User

  • Optional. Object Construct

  • Slack Custom API Action

  1. Retrieve the User ID from Slack with the Read User card.

  2. Optionally, include the Object Construct card to pass the users:ID_VALUE into the Custom API Action card.

  3. To return the user's information, use the Custom API Action card. This card might need to be added in the relative URL section. The Query value needs to be in the following format {"users":"ID_VALUE"}. This is equivalent to having ?users=ID_VALUE at the end of an HTTP URL.

  4. Run the flow. When the operation is finished, the output in the JSON body should be similar to the following.

Copy
{
"ok":true,
"users":[
{
"id":"UDS5S7MFV",
"team_id":"T6WPNMPFU",
"name":"jessie.doe",
"deleted":false,
"color":"9b3b45",
"real_name":"Jessie Doe",
"tz":"America/Los_Angeles",
"tz_label":"Pacific Daylight Time",
"tz_offset":-25200,
"profile":{
"title":"Director, Customer Service",
"phone":"",
"skype":"",
"real_name":"Jessie Doe",
"real_name_normalized":"Jessie Doe",
"display_name":"jdoe",
"display_name_normalized":"jdoe",
"fields":null,
"status_text":"OOO",
"status_emoji":":mountain:",
"status_emoji_display_info":[

],
"status_expiration":0,
"avatar_hash":"394fdd4baa40",
"image_original":"https://avatars.slack-edge.com/2018-11-15/480801844498_394fdd4baa4039df7a4c_original.jpg",
"is_custom_image":true,
"email":"jessie.doe@example.com",
"huddle_state":"default_unset",
"first_name":"Jessie",
"last_name":"Doe"
},
"is_admin":false,
"is_owner":false,
"is_primary_owner":false,
"is_restricted":false,
"is_ultra_restricted":false,
"is_bot":false,
"is_app_user":false,
"updated":1653018345,
"is_email_confirmed":true,
"has_2fa":false,
"who_can_share_contact_card":"EVERYONE",
"enterprise_user":{
"id":"UDS5S7MFV",
"enterprise_id":"E017NDYFGQL",
"enterprise_name":"Atko",
"is_admin":false,
"is_owner":false,
"teams":[
"T6WPNMPFU"
]
}
}
]
}

Extract user information

Use the Slack Get card to extract the user data from the JSON body.

The output type has to be an object and a list.

Use the List At card to get the first value of the list (index = 0). Then use the Object Get function card to find the specific profile.status_text.

Finally, verify that the status_text value is present and has the correct value.

Related topics

Functions

Workflow elements