Slack
The Slack component is an application component that allows users to get and send message on Slack. It can carry out the following tasks:
Release Stage
Alpha
Configuration
The component definition and tasks are defined in the definition.yaml and tasks.yaml files respectively.
Setup
In order to communicate with Slack, the following connection details need to be
provided. You may specify them directly in a pipeline recipe as key-value pairs
within the component's setup
block, or you can create a Connection from
the Integration Settings
page and reference the whole setup
as setup: ${connection.<my-connection-id>}
.
Field | Field ID | Type | Note |
---|---|---|---|
Bot OAuth Token (required) | bot-token | string | Token associated to the application bot. |
User OAuth Token | user-token | string | Token to act on behalf of a Slack user. |
Connecting through a Slack App
The Slack component connects with your workspace via a Slack App. In order to read / write messages from / to Slack, you'll need to:
- Add the app to your workspace.
- Add the app to the channels you want to interact with.
The Slack integration on Instill Cloud uses OAuth 2.0 to connect with Slack
via the instill-ai
app. There, creating a
connection
will simply require authenticating on Slack. Your newly created connection,
which you can reference in your pipelines, will allow you to read messages and
send them on behalf of your user or the instill-ai
bot on the channels where
that app is installed.
If you want to connect with Slack via OAuth 2.0 on Instill Core, you will need to provide your app's client ID and client secret as environment variables on Instill Core.
Supported Tasks
Read Message
Get the latest message since specific date
Input | Field ID | Type | Description |
---|---|---|---|
Task ID (required) | task | string | TASK_READ_MESSAGE |
Channel Name (required) | channel-name | string | Channel name, as displayed on Slack. |
Start to Read Date | start-to-read-date | string | Date (in YYYY-MM-DD format) from which messages will start to be fetched. If not provided, it will be 7 days before the current date. The date will be in the UTC timezone. |
Output | Field ID | Type | Description |
---|---|---|---|
Conversations | conversations | array[object] | An array of conversations with thread messages. |
Output Objects in Read Message
Conversations
Field | Field ID | Type | Note |
---|---|---|---|
Last Date | last-date | string | Date of the last message. |
Start Conversation Message | message | string | message to start a conversation. |
Start Date | start-date | string | when a conversation starts. |
Replied messages | thread-reply-messages | array | replies in a conversation. |
User UID | user-id | string | unique id from Slack. |
User Name | user-name | string | user name in Slack. |
Replied Messages
Field | Field ID | Type | Note |
---|---|---|---|
Replied Time | datetime | string | replied datetime. |
Replied Message | message | string | message to reply a conversation. |
User UID | user-id | string | unique id from Slack. |
User Name | user-name | string | user name in Slack. |
Send Message
send message to a specific channel
Input | Field ID | Type | Description |
---|---|---|---|
Task ID (required) | task | string | TASK_WRITE_MESSAGE |
Channel Name (required) | channel-name | string | Channel name, as displayed on Slack. |
Message (required) | message | string | The message to be sent to the target channel. |
Send As User | as-user | boolean | Send the message on behalf of the user identified by the setup.user-token field. |
Output | Field ID | Type | Description |
---|---|---|---|
Result | result | string | Result of the message delivery. |
Supported Events
New Message Event
A new message event from Slack.
Configuration | ID | Type | Description |
---|---|---|---|
Channel Names (required) | channel-names | array[string] | Names of the Slack channels to listen to. |
Event Message Objects
Channel
Field | Field ID | Type | Note |
---|---|---|---|
Channel ID | id | string | Unique ID of the Slack channel. |
Channel Name | name | string | Name of the Slack channel. |
User
Field | Field ID | Type | Note |
---|---|---|---|
User ID | id | string | Unique ID of the Slack user. |
User Name | name | string | Username of the Slack user. |
Real Name | real-name | string | Real name of the Slack user. |
Profile | profile | object | User profile information. |
Profile
Field | Field ID | Type | Note |
---|---|---|---|
Display Name | display-name | string | Display name of the Slack user. |
Example Recipes
Send a message to Slack when a new message is posted in a channel
version: v1beta
on:
slack-0:
type: slack
event: EVENT_NEW_MESSAGE
config:
channel-names:
- channel-to-be-listened
setup: ${connection.my-slack-connection}
variable:
message:
title: message
type: string
listen:
- ${on.slack-0.message.text}
user:
title: user
type: string
listen:
- ${on.slack-0.message.user.name}
channel:
title: channel
type: string
listen:
- ${on.slack-0.message.channel.name}
component:
slack-0:
type: slack
input:
channel-name: channel-for-notification
message: Message received in #${variable.channel} from @${variable.user}: ${variable.message}
as-user: false
condition:
setup: ${connection.my-slack-connection}
task: TASK_WRITE_MESSAGE
Updated about 6 hours ago