Skip to main content

Read Slack Message

The Read Slack Message activity retrieves messages from a Slack channel that were posted after a specific timestamp.

Purpose

Use the Read Slack Message activity to:

  • Read replies to messages sent by workflows
  • Implement interactive workflow patterns
  • Wait for user responses in Slack
  • Process feedback or approvals via Slack

Prerequisites

Slack Connection Required

  • Must have a configured Slack connection (see Settings → Connections)
  • OAuth token must have channels:read and channels:history permissions

Message Timestamp Required

  • Typically used after a Send Slack Message activity
  • Requires the timestamp of a previously sent message
  • Use context variables to pass timestamps between activities

Configuration

Connection Settings

  • Slack Connection: Select a pre-configured Slack connection

Channel Settings

  • Channel Name: The Slack channel to read from (e.g., "products")
  • Channel ID: Alternative to channel name

Timestamp Settings

  • Timestamp: Reference to a timestamp variable (e.g., {MySlackMessageTimestamp})
  • Only messages after this timestamp will be retrieved

Output Context Variables

The activity returns three values that should be stored in workflow variables:

  1. Read Timestamp: Timestamp of the message that was read
  2. Username: The Slack username of the person who sent the message
  3. Message: The content of the message

Context Variables Configuration

Read Timestamp Context Key: SlackReadTimestamp
Username Context Key: SlackUsername
Message Context Key: SlackMessage

These variables can then be used in subsequent workflow activities.

How It Works

Reading Process

  1. Activity connects to Slack channel
  2. Retrieves messages posted after the provided timestamp
  3. Returns the first message found
  4. Stores message details in workflow variables

Sequential Reading

To read multiple messages:

  1. First read stores its timestamp in a variable
  2. Second read uses that timestamp to get the next message
  3. Continue in a loop to process all messages

Usage Patterns

Send and Wait for Reply

1. Send Slack Message
└─ Store timestamp in: InitialMessageTimestamp

2. Delay (e.g., 5 minutes to allow response time)

3. Read Slack Message
└─ Timestamp: {InitialMessageTimestamp}
└─ Store: ReadTimestamp, Username, Message

4. Process response (If activity, Script, etc.)

Loop Through Multiple Messages

1. Send Slack Message → Store: CurrentTimestamp

2. Delay (wait for responses)

3. Read Slack Message
└─ Timestamp: {CurrentTimestamp}
└─ Store response in: CurrentTimestamp (overwrites), Username, Message

4. If (message found)
└─ Process message
└─ Loop back to step 3 (reads next message)

5. If (no more messages)
└─ Continue workflow

Interactive Approval

1. Send Slack Message: "Approve? (yes/no)"
└─ Store: ApprovalTimestamp

2. Delay (wait for response)

3. Read Slack Message
└─ Timestamp: {ApprovalTimestamp}
└─ Store: ResponseTimestamp, ApproverUsername, ResponseMessage

4. If ({ResponseMessage} contains "yes")
└─ Approved branch
5. Else
└─ Rejected branch

Example Configuration

Basic Message Reading

Slack Connection: Company Slack
Channel: products
Timestamp: {InitialMessageTimestamp}
Read Timestamp Context Key: NextTimestamp
Username Context Key: ResponderName
Message Context Key: ResponseText

After Sending

1. Send Slack Message Activity:
Message: "Please confirm: Proceed with data load? (yes/no)"
Store Timestamp: QuestionTimestamp

2. Read Slack Message Activity:
Timestamp: {QuestionTimestamp}
Store: ReplyTimestamp, ResponderUsername, ReplyMessage

3. Log Message:
Message: "Received response from @ResponderUsername: @ReplyMessage"

Returned Data

Read Timestamp

  • Timestamp of the message that was read
  • Use this to read subsequent messages
  • Can replace the original timestamp variable to iterate

Username

  • Slack username of the message sender
  • Format: Usually the Slack display name or username
  • Use for logging, routing, or verification

Message

  • The actual text content of the message
  • Can be processed with If activity for conditional logic
  • Supports parameter substitution in subsequent activities

Loop Pattern for Multiple Messages

┌─> Read Slack Message
│ ├─ Timestamp: {CurrentTimestamp}
│ └─ Store: CurrentTimestamp, Username, Message

├─> If (Message is not empty)
│ ├─ [Yes] Process Message
│ │ └─> Loop back to Read
│ └─ [No] Exit loop

└─> Continue workflow

This pattern reads all messages posted after the initial timestamp.

Best Practices

  • Add Delays: Allow time for users to respond before reading
  • Handle Empty Results: Check if a message was found before processing
  • Store Timestamps: Always store read timestamp for iteration
  • Message Validation: Verify message content format before acting on it
  • User Verification: Consider validating the responding user
  • Timeout Pattern: Combine with Delay and Stop for timeout scenarios
  • Clear Instructions: Send clear, structured questions when expecting replies

Common Issues

No Messages Found

  • Timestamp is too recent (no messages posted yet)
  • Wrong channel specified
  • Bot not added to the channel
  • OAuth token lacks channels:history permission

Reading Same Message Repeatedly

  • Not updating the timestamp variable
  • Using the original timestamp instead of the read timestamp
  • Check that context variables are properly configured

Unexpected Message Format

  • Users didn't respond in expected format
  • Multiple users responded (first message returned)
  • Message contains formatting or emojis

Limitations

  • Reads one message at a time (first message after timestamp)
  • Requires explicit timestamp reference
  • Cannot filter by user or content in the activity itself (use If activity)
  • No built-in timeout (combine with Delay and conditional logic)

Security Notes

  • Messages may contain sensitive data
  • Validate message content before acting on it
  • Log who responded for audit purposes
  • Consider channel access controls in Slack
  • Be aware of Slack message retention policies

OAuth Permissions Required

For IT team/Slack admin, the Slack App needs:

  • channels:read - List and read channel information
  • channels:history - Read channel message history
  • chat:write - Send messages (if using with Send Slack Message)

Troubleshooting

Messages Not Being Read

  1. Verify bot has channels:history permission
  2. Check bot is member of the channel
  3. Confirm timestamp variable has valid value
  4. Review workflow execution log for errors
  5. Test in Slack to verify messages exist

Wrong Message Retrieved

  1. Verify timestamp is from the correct message
  2. Check if multiple users responded (first one is returned)
  3. Ensure timestamp format is correct
  4. Consider adding delay for message propagation