Slack
This page provides information for connecting Appsmith to Slack, which allows you to retrieve user and channel details, send messages, and automate notifications.
Connect Slack
The following section is a reference guide that provides a complete description of all the parameters to connect to an Slack datasource.
Authentication
You can authenticate using OAuth 2.0. If you are already logged into Slack in your browser, the active workspace is selected automatically. You can choose a different workspace from the dropdown in the top-right corner of the authorization screen and click Allow to connect Slack to Appsmith.
Query Slack
The following section is a reference guide that provides a description of the available commands with their parameters to create Slack queries.
List Members
The List Members command retrieves a list of all users in the Slack workspace. It returns each user’s name and id in an array format This can be used to fetch user IDs for sending messages or referencing users in queries.
List Channels
The List Channels command retrieves a list of all public channels in the Slack workspace that you are a member of. It returns channel names in an array format under the records key. This can be used to fetch available channels for sending messages or retrieving channel-specific data.
Get User By Email
The Get User By Email command retrieves user details based on their email address. It returns all details related to the user, including id, team_id, profile information, timezone, and two-factor authentication method. This is useful for identifying users, fetching their Slack IDs for messaging, or retrieving profile details for automation.
Email string
This property allows you to specify the email address of the user whose details you want to retrieve. Providing a valid email returns the user's ID, profile information, and workspace association.
Example: If you want to dynamically pass the email address based on the selected row in a table widget, use:
{{Table1.selectedRow.email}}
// Example: "john.doe@example.com"
Search Messages
The Search Messages command retrieves messages from Slack channels based on a search query. It scans messages across public channels and returns results matching the specified keywords. You can refine the search using filters like date range, user ID, or specific channels to narrow down results.
Query string
This property specifies the search term used to find messages in Slack. It supports keywords, phrases, and filters to refine search results.
Example 1: If you want to search for messages based on user input from a Input widget, use:
{{Input1.text}}
// Git project update
Example 2: If you want to find messages from a specific user within a date range using a Datepicker widget, use:
from:@{{UserDropdown.selectedOptionValue}} after:{{Datepicker1.selectedDate}} before:{{Datepicker2.selectedDate}}
// from:@U0B123XX after:2025-01-01 before:2025-02-01
Example 3: If you want to search for messages in a specific channel using a Select widget, use:
in:#{{ChannelSelect.selectedOptionValue}} {{Input1.text}}
// in:#team-tech database migration
Send Direct Message
The Send Direct Message command sends a private message to a specific user on Slack. It allows direct communication with a user by providing their Slack ID. This command creates a direct message conversation if one does not already exist and returns details of the message sent, including the message ID, timestamp, and channel ID. This is useful for sending automated alerts, notifications, or personalized messages.
Member id string
The Member ID specifies the recipient of the direct message. It is the unique Slack user ID required to send a message to an individual user. You can retrieve this ID using the List Members or Get User By Email command. If no Member ID is provided, the message defaults to the authenticated user.
In workflows where users need to select a recipient dynamically, you can use Connect Portal Workflow Settings to allow selection from a predefined list of workspace members.
Example: If you want to dynamically select a recipient from a Select widget, use:
{{UserSelect.selectedOptionValue}}
// Example: "U03B8PXXXX"
Message string
The Message parameter specifies the content of the direct message to be sent. It supports plain text, formatted text, and variables for dynamic content.
Example: If you want to send a message dynamically using an Input widget:
{{MessageInput.text}}
// Example: "Hello, your request has been approved!"
Bot name string
The Bot Name specifies the name of the bot that sends the message.
-
Bot is already created: The message is sent using the specified bot name, provided the bot exists in the Slack workspace.
-
Bot does not exist: If the provided bot name is not found, the message is sent using "Appsmith" as the bot name by default.
-
No bot name provided: If the bot name field is left empty, Slack automatically assigns "Appsmith" as the sender.
Example: Set bot name dynamically using an Input widget
{{BotNameInput.text}}
// Example: "SupportBot"
Bot icon string
The bot icon defines the avatar displayed alongside messages sent by the bot. It can be either:
- An image URL, pointing to a publicly accessible image. (e.g.,
https://example.com/bot-avatar.png). - An emoji, using the Slack emoji format (e.g.,
:dog:).
If no bot icon is provided, Slack assigns the default bot avatar.
Block string
The Block parameter allows you to send structured messages using Slack's Block Kit, a JSON-based UI framework for creating rich, interactive messages. Blocks enable formatting options like sections, buttons, images, and attachments.
If provided, the Block parameter overrides the plain text message and sends the structured content instead.
[
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Hello, this is a test message!"
}
}
]
Authenticated User boolean
Specifies whether the message is sent as the authenticated Slack user. When enabled, the message is sent from the logged-in user who authenticated the connection, appearing as a self-DM in direct messages. If disabled (default), the message is sent from the application, typically using the configured bot name. Ensure the authenticated user has the necessary permissions to send messages.
Send Message
The Send Message command posts a message to a specified Slack channel. It allows sending text messages, formatted messages using Block Kit, or attachments. The message can be sent as a bot or as the authenticated user, depending on the configuration. This command supports additional options like setting a bot name, bot icon, and message formatting.