sym.sdk.integrations.slack

Helpers for interacting with a Slack workspace.

Functions

channel(name[, allow_self])

A reference to a Slack channel.

fallback(*channels)

An instruction to try a series of slack.channel, slack.user, and slack.group until one succeeds.

group(users[, allow_self])

A reference to a Slack group.

send_message(destination, message)

Sends a simple message to a destination in Slack.

user(identifier)

A reference to a Slack user.

Classes

SlackChannel

SlackLookupType

An enumeration.

class sym.sdk.integrations.slack.SlackChannel(lookup_type: sym.sdk.integrations.slack.SlackLookupType, lookup_keys: List[Union[str, sym.sdk.user.User]], allow_self: bool = True)

Bases: object

class sym.sdk.integrations.slack.SlackLookupType(value)

Bases: str, enum.Enum

An enumeration.

sym.sdk.integrations.slack.channel(name: str, allow_self: bool = False) sym.sdk.integrations.slack.SlackChannel

A reference to a Slack channel.

Parameters
  • name – The channel name to send the message to.

  • allow_self – Whether to allow the current user to approve their own request.

sym.sdk.integrations.slack.fallback(*channels: sym.sdk.integrations.slack.SlackChannel) sym.sdk.integrations.slack.SlackChannel

An instruction to try a series of slack.channel, slack.user, and slack.group until one succeeds.

e.g. slack.fallback(slack.channel(“#missing”), slack.user(“@david”))

Parameters

channels – any number of channel, group and user.

sym.sdk.integrations.slack.group(users: Sequence[Union[str, sym.sdk.user.User]], allow_self: bool = False) sym.sdk.integrations.slack.SlackChannel

A reference to a Slack group.

Parameters

users (Sequence[Union[str, User]]) – A list of either Sym User objects or emails.

sym.sdk.integrations.slack.send_message(destination: Union[sym.sdk.user.User, sym.sdk.integrations.slack.SlackChannel], message: str) None

Sends a simple message to a destination in Slack. Accepts either a User or a SlackChannel, which may represent a user, group, or channel in Slack.

For example:

# To send to #general:
slack.send_message(slack.channel("#general"), "Hello, world!")

# To DM a specific user:
slack.send_message(slack.user("me@symops.io"), "It works!")

# To DM the user who triggered an event:
slack.send_message(event.user, "You did a thing!")
Parameters
  • destination – where the message should go.

  • message – the text contents of the message to send.

sym.sdk.integrations.slack.user(identifier: Union[str, sym.sdk.user.User]) sym.sdk.integrations.slack.SlackChannel

A reference to a Slack user.

Users can be specified with a Slack user ID, email, or Sym User instance.