- sym.sdk.integrations.slack.users_in_channel(channel: Union[sym.sdk.request_destination.SlackChannelID, sym.sdk.request_destination.SlackChannelName, str]) List[sym.sdk.user.User] ¶
Retrieves the users in a given Slack channel as a list of
“Channel” here includes all Slack conversation types, including public and private channels as well as groups.
channelargument can either be given as the output of the
channel()function, or as a string containing a Slack channel name or ID. If a channel name is given in a string, it must be prefixed with
The output is a list of
Userobjects, suitable for use in other areas of the Sym SDK. For example, to easily restrict the ability to approve or deny requests (including in the Sym webapp) to members of a Slack channel, one can use:
@reducer def get_permissions(event): return RequestPermission( webapp_view=PermissionLevel.MEMBER, approve_deny=user_ids(slack.users_in_channel("#managers")), allow_self_approval=False )
However, please see the “Cautions” below for some important caveats when using this function.
(For more information on the
get_permissions()reducer, please see the docs.)
Using this function introduces a hard dependency on Slack in your Sym Flow, which may have unintended effects; for example, during a Slack outage when the Slack API is unavailable. If you must use this function in such a way, wrap the call in a
exceptblock and include backup logic in the
exceptblock. In the above example, you may wish to set
exceptblock, for instance, so that admins can still action requests in the webapp even if Slack is down.
This function may cause your Flow to experience a reducer timeout for large Slack channels, or if your Slack workspace has a very large number of total users or total channels. Test your usage to ensure that it works as expected. Using a channel ID instead of a channel name may improve performance.
To use this function with a private channel, the Sym app for Slack must be a member of that channel; otherwise, this function will raise a channel not found exception.
If this function is used with a Slack Connect channel or in a channel containing Slack guest users, any users from outside your organization will be included in the output.
channel – A
SlackChannelName, or string representing the channel ID or name.
A list of User objects representing the users in the channel, or an empty list if the channel is empty.
SlackError – If the channel is not found or another error occurs while interacting with the Slack API.