You spend your day in Slack, responding to DM's, sharing memes, talking about production, and now getting access to resources with Sym.

It is easy to request access and use your organization's workflow and approval logic via Sym's Slack Integration.

Using Slack in your Flow

This section is for Sym Implementers!

If your Slack Integration has not yet been set up, please point your Integrator to Setup Slack.

πŸ‘

SDK Docs

The Slack Integration is defined at sym.sdk.integrations.slack.

Example Usage

Terraform

Here is an example of using Sym's Terraform Provider to declare a Slack Integration.

resource "sym_integration" "slack" {
  type = "slack"
  name = "slack-${var.environment}"
  settings = {
    workspace_id = "T1234567890"
  }
}

Python

Route a request to a channel

This example returns a Slack channel in the get_approvers reducer of a sym:approval template, which results in a request being sent to a channel.

from sym.sdk.annotations import hook, reducer
from sym.sdk.integrations import slack

@reducer
def get_approvers(evt):
    if evt.payload.fields["urgency"] == "High":
        # This is a self-approval in a channel
        return slack.channel("#break-glass", allow_self=True)
    return slack.channel("#ops")

Route a request to a DM

This example uses the PagerDuty Integration to selectively DM a Slack user.

from sym.sdk.annotations import hook, reducer
from sym.sdk.integrations import pagerduty, slack

@reducer
def get_approvers(evt):
    # The `pagerduty` import uses the creds from the TF integration.
    # It knows how to take in a sym.User & check if that User is 
    # on call for a given schedule.
    if pagerduty.is_on_call(evt.user, escalation_policy_name="sre"):
        # This is a self-approval in a DM
        return slack.user(evt.user)

Route a request to a group DM

This example returns a group of users to DM with an access request.

🚧

Slack's conversations.open endpoint for direct messages accepts up to 8 users.

from sym.sdk.annotations import hook, reducer
from sym.sdk.integrations import pagerduty, slack

@reducer
def get_approvers(evt):
    on_call_mgrs = pagerduty.users_on_call(schedule_id="PXUGCWM")
    return slack.group([u for u in on_call_mgrs][:7])

What’s Next
Did this page help you?