Slack Connector

Send messages, manage channels, upload files, and automate Slack workflows

Slack Connector

Connect your workflows to Slack and automate team communication. Send notifications, manage channels, upload files, and build interactive messages—all from DeepChain.

Overview

The Slack connector provides 8 operations for integrating Slack into your automation workflows. Perfect for sending alerts, updates, approvals, and anything else that needs team attention.

Authentication

Slack uses OAuth for secure authentication:

auth_type: oauth2
client_id: "your_app_client_id"
client_secret: "your_app_secret"
scopes:
  - chat:write
  - channels:read
  - users:read

How to set it up:

  1. Go to api.slack.com > Your Apps and create a new app
  2. Under OAuth & Permissions, set redirect URI: https://yourapp.deepchain.dev/oauth/callback
  3. Add these Bot Token Scopes:
    • chat:write — Send messages
    • channels:read — See channel list
    • users:read — Get user info
    • files:write — Upload files
  4. Click Install to Workspace and authorize
  5. Copy your Bot User OAuth Token (starts with xoxb-)

Available Operations

Here's what you can do with Slack:

Operation What It Does
postMessage Send a message to a channel
updateMessage Edit an existing message
deleteMessage Remove a message
listChannels List all channels in the workspace
getChannelInfo Get details about a channel
listUsers List all workspace members
getUserInfo Get details about a user
uploadFile Upload a file to a channel

Practical Workflow Examples

Example 1: Send a Simple Notification

Alert your team when something happens:

- id: notify_team
  type: slack_connector
  config:
    operation: postMessage
    channel: "#notifications"
    text: "Deployment started for {{ input.service }}"

Example 2: Send a Rich Message with Blocks

Use Slack's Block Kit for formatted messages with colors and structure:

- id: send_deployment_update
  type: slack_connector
  config:
    operation: postMessage
    channel: "#deployments"
    blocks:
      - type: section
        text:
          type: mrkdwn
          text: "*Deployment Complete* ✅\nService: {{ input.service }}\nVersion: {{ input.version }}"
      - type: section
        fields:
          - type: mrkdwn
            text: "*Environment:*\n{{ input.environment }}"
          - type: mrkdwn
            text: "*Duration:*\n{{ input.duration }} minutes"
      - type: divider
      - type: context
        elements:
          - type: mrkdwn
            text: "Deployed by {{ input.deployed_by }} at {{ input.timestamp }}"

Example 3: Send a Message with Action Buttons

Request approval directly in Slack:

- id: request_approval
  type: slack_connector
  config:
    operation: postMessage
    channel: "#approvals"
    blocks:
      - type: section
        text:
          type: mrkdwn
          text: "*Approval Required*\nExpense Report: ${{ input.amount }}\nSubmitted by: {{ input.submitted_by }}"
      - type: section
        text:
          type: mrkdwn
          text: "{{ input.description }}"
      - type: actions
        elements:
          - type: button
            text:
              type: plain_text
              text: "Approve"
            style: primary
            value: "approve_{{ input.request_id }}"
            action_id: "approve_{{ input.request_id }}"
          - type: button
            text:
              type: plain_text
              text: "Reject"
            style: danger
            value: "reject_{{ input.request_id }}"
            action_id: "reject_{{ input.request_id }}"

Example 4: Route Messages to Different Channels

Send messages to the right channel based on severity:

- id: route_alert
  type: slack_connector
  config:
    operation: postMessage
    channel: "{{ if(input.severity == 'critical', '#critical-alerts', '#general-alerts') }}"
    text: "[{{ upper(input.severity) }}] {{ input.message }}"

Example 5: Update an Existing Message

Edit a message you sent earlier (useful for progress updates):

- id: update_progress
  type: slack_connector
  config:
    operation: updateMessage
    channel: "#progress"
    timestamp: "{{ input.message_ts }}"  # The timestamp of the message to update
    blocks:
      - type: section
        text:
          type: mrkdwn
          text: "*Processing Status*\nProgress: {{ input.progress_percent }}%\n⏳ Processing {{ input.current_item }} of {{ input.total_items }}"

Example 6: Upload a File to a Channel

Share reports, logs, or generated files:

- id: upload_report
  type: slack_connector
  config:
    operation: uploadFile
    channel: "#reports"
    title: "Daily Sales Report"
    filename: "sales-report-{{ formatDate(now(), 'yyyy-MM-dd') }}.csv"
    content: "{{ input.csv_data }}"

Example 7: Find a User and DM Them

Send a direct message to a team member:

- id: find_user
  type: slack_connector
  config:
    operation: listUsers
    filter: "{{ input.user_email }}"

- id: send_dm
  type: slack_connector
  config:
    operation: postMessage
    channel: "@{{ find_user_1.response.username }}"
    text: "Hey! {{ input.message }}"

Slack Block Kit Reference

Slack supports rich message formatting with blocks. Here are the main types:

Section Block

Simple text content:

- type: section
  text:
    type: mrkdwn
    text: "*Bold text* and _italic text_"

Divider Block

Visual separator:

- type: divider

Image Block

Embed an image:

- type: image
  image_url: "{{ input.image_url }}"
  alt_text: "Image description"

Actions Block

Add buttons and interactive elements:

- type: actions
  elements:
    - type: button
      text:
        type: plain_text
        text: "Click Me"
      action_id: "button_click"

Context Block

Small secondary information:

- type: context
  elements:
    - type: mrkdwn
      text: "Posted by {{ input.user }} at {{ input.timestamp }}"

Rate Limits

Slack enforces rate limits based on method tier:

  • Tier 1 methods (postMessage): 1 request per second
  • Tier 2 methods (listChannels): 20 requests per minute
  • Tier 3 methods (getChannelInfo): 50 requests per minute
  • Tier 4 methods (listUsers): 100+ requests per minute

Note: DeepChain handles rate limiting automatically with backoff and queuing.

Error Handling

Common Slack Errors

Error What It Means How to Fix
channel_not_found Channel doesn't exist Check the channel name/ID (no # symbol)
not_in_channel Bot isn't in the channel Invite the bot to the channel manually
rate_limited Hitting rate limits Slow down; DeepChain will retry automatically
invalid_auth Bad token Re-authenticate in Credentials
missing_scope Missing required permissions Update bot scopes and reinstall

Debugging

Enable debug logging:

Node Configuration:
  debug: true
  logRequest: true
  logResponse: true

Check execution logs for detailed error messages.

Best Practices

1. Use Markdown for Rich Text

Make messages readable and eye-catching:

text: |
  *Order Confirmed*
  Order #{{ input.order_id }}

   Customer: {{ input.customer_name }}
   Total: ${{ input.total }}
   Status:  Confirmed

2. Use Channel Names or IDs

Both work, but be consistent:

# Channel name (no # symbol)
channel: "notifications"

# Channel ID (usually more reliable)
channel: "C0XXXXXXXXX"

3. Format Timestamps for Readability

Slack has a special format for timestamps:

text: "Posted at <!date^{{ formatDate(now(), 'x') }}/^{date} {time}|{{ formatDate(now(), 'yyyy-MM-dd HH:mm') }}>"

4. Store Message Timestamps for Editing

If you plan to edit messages, store the timestamp:

- id: send_message
  type: slack_connector
  config:
    operation: postMessage
    channel: "#updates"
    text: "Downloading..."

# Next node can use: {{ send_message_1.response.ts }}

5. Test Blocks in the Block Kit Builder

Slack's Block Kit Builder is great for testing block syntax before using them in workflows.


Next Steps