Slack
Send messages and collect responses via Slack channels or DMs
Configuration
Option 1: Using the HumanLayer Slack App
The quickest way to get started with Slack integration:
- Head to the HumanLayer dashboard
- Navigate to “Integrations”
- Click “HumanLayer App” under the Slack section
- Follow the Slack Approval Workflow
- Congrats - your HumanLayer agents will now contact you in Slack for approvals
Option 2: Using Your Own Slack App
For teams that need more customization, you can use your own Slack app. This option is ideal for:
- Customizing the bot’s display name, icon, and branding
- Using a consistent bot identity across multiple integrations
- Managing app distribution and permissions at an organizational level
- Custom approval UI with your brand’s look and feel
- Enterprise policy compliance
- Create a Slack App - Create a new Slack app in your workspace with the following manifest:
-
Configure Your App in HumanLayer:
- In the HumanLayer dashboard, navigate to your project’s settings
- Navigate to “Integrations”. Select “Use Your Own” under the Slack section.
- Enter your Slack app’s Signing Secret and App ID
- Save the configuration
-
Get Your OAuth Token:
- For testing, you can use the Bot User OAuth Token from your Slack app settings
- For production, implement a proper OAuth flow following Slack’s documentation
-
Use Your Bot Token with HumanLayer SDK:
- When initializing HumanLayer, provide your bot token in the contact channel configuration:
For a complete example that makes use of a custom Slack app, see 06-custom_bot_token.py in our examples
directory. Be sure you have a Slack application setup before attempting to run the script.
Troubleshooting
If you encounter issues with your custom Slack app integration:
- Verify Scopes - Ensure your app has all the required scopes listed in the manifest
- Check Request URLs - The event subscription and interactivity URLs must point to the HumanLayer API
- Verify Signing Secret - Double-check the signing secret entered in the HumanLayer dashboard
- Update/Reauthorize Slack Apps - If you’re updating an existing Slack app and have added new scopes, you’ll need to reauthorize the app via the OAuth flow you’ve built. Be sure to take a look at the embedded markup Slack provides in the “Manage Distribution” section of your app’s settings as these links and markup can change once you’ve updated scopes.
Customizing Channels
The Slack contact channel allows agents to send messages and collect responses through Slack channels or direct messages.
Configure a Slack channel using the SlackContactChannel
model:
Allowed Responders
You can restrict which Slack users are allowed to respond to a message using allowed_responder_ids
:
The allowed_responder_ids
must be Slack user IDs (starting with U
). Messages from other users will be ignored.
See 01-math-example-allowed-repliers.py for a complete example.
Thread Messages
You can specify a thread to post messages in using the thread_ts
parameter:
The thread_ts
parameter accepts a Slack message timestamp (e.g. “1234567890.123456”) which identifies the parent message of the thread. When specified, all messages will be posted as replies in that thread instead of as new messages in the channel.
This is useful for organizing related approvals or keeping discussions contained within specific threads.
Channel/User ID
The channel_or_user_id
must be a Slack ID:
- Channel IDs start with
C
(e.g.C123456
) - User IDs start with
U
(e.g.U123456
) - Do not use channel names (
#general
) or usernames (@user
)
You can get a channel ID in slack by right-clicking the channel, going to “Channel Details”, and copying the ID at the bottom of the modal.
You can also override the contact channel at the per-request level:
Or in one or more human-as tool instances
Context
The optional context_about_channel_or_user
field helps the LLM understand who it’s talking to:
Usage
Use the Slack channel with either core feature: