# Communication with Slack

<!-- Generated by tools/catalogue/generate.py from flow.service.workflow 5.0.0-beta.39. Don't edit by hand. -->

# Communication with Slack

The Communication with Slack category has 13 tasks. Each entry shows the task's latest revision, the one the palette adds. See [Reading an entry](https://www.useboomerang.io/docs/flow/main/catalogue/overview#reading-an-entry).

## Create Slack Channel

Create a Slack channel using a Slack application through Bot tokens. For further reading on the underlying API see https://api.slack.com/methods/conversations.create

- **Slug:** `create-slack-channel`
- **Type:** `template`
- **Revision:** 3
- **Image:** Default task image.

**Parameters**

| Label | Name | Type | Required | Default | Helper text |
| --- | --- | --- | --- | --- | --- |
| Authentication API Token | `token` | Secured | Yes | `$(workspace.params.slack-token)` | The token is associated with the slack application |
| Channel Name | `name` | Text | Yes |  | Name of the public or private channel to create |
| Private Channel | `isPrivate` | Boolean | No | `false` |  |
| Team | `team` | Text | No |  | Encoded team id to create the channel in |

**Results**

| Name | Description |
| --- | --- |
| `response` | The newly created slack channel |

## Delete Slack Channel

Archives a Slack conversation using a Slack application through Bot tokens. For further reading on the underlying API see https://api.slack.com/methods/conversations.archive

- **Slug:** `delete-slack-channel`
- **Type:** `template`
- **Revision:** 3
- **Image:** Default task image.

**Parameters**

| Label | Name | Type | Required | Default | Helper text |
| --- | --- | --- | --- | --- | --- |
| Authentication API Token | `token` | Secured | Yes | `$(workspace.params.slack-token)` | The token is associated with the slack application |
| Channel ID | `channel` | Text | Yes |  | ID of conversation to archive |

**Results**

| Name | Description |
| --- | --- |
| `response` | Status of the delete slack channel action |

## Find Slack Member By Email

Find a Slack user based on the provided email address using a Slack application through Bot tokens. For further reading on the underlying API see https://api.slack.com/methods/users.lookupByEmail

- **Slug:** `find-slack-member-by-email`
- **Type:** `template`
- **Revision:** 4
- **Image:** Default task image.

**Parameters**

| Label | Name | Type | Required | Default | Helper text |
| --- | --- | --- | --- | --- | --- |
| Authentication API Token | `token` | Secured | Yes | `$(workspace.params.slack-token)` | The token is associated with the slack application |
| Email Address | `emailAddress` | Text | Yes |  | An email belonging to a user in the workspace |

**Results**

| Name | Description |
| --- | --- |
| `slackUserId` | The slack user id |

## Find Slack Member By Id

Find a Slack user based on the provided user id using a Slack application through Bot tokens. For further reading on the underlying API see https://api.slack.com/methods/users.info

- **Slug:** `find-slack-member-by-id`
- **Type:** `template`
- **Revision:** 3
- **Image:** Default task image.

**Parameters**

| Label | Name | Type | Required | Default | Helper text |
| --- | --- | --- | --- | --- | --- |
| Authentication API Token | `token` | Secured | Yes | `$(workspace.params.slack-token)` | The token is associated with the slack application |
| User | `user` | Text | Yes |  | User id to get info on |

**Results**

| Name | Description |
| --- | --- |
| `response` | Slack user details |

## Get Slack Channel Info

Retrieves the Slack channel information using a Slack application through Bot tokens. For further reading on the underlying API see https://api.slack.com/methods/conversations.info

- **Slug:** `get-slack-channel-info`
- **Type:** `template`
- **Revision:** 3
- **Image:** Default task image.

**Parameters**

| Label | Name | Type | Required | Default | Helper text |
| --- | --- | --- | --- | --- | --- |
| Authentication API Token | `token` | Secured | Yes | `$(workspace.params.slack-token)` | The token is associated with the slack application |
| Channel | `channel` | Text | Yes |  | Conversation ID to learn more about |

**Results**

| Name | Description |
| --- | --- |
| `response` | Slack channel details |

## Get Slack Channel Members

Retrieve the Slack channel members using a Slack application through Bot tokens. For further reading on the underlying API see https://api.slack.com/methods/conversations.members

- **Slug:** `get-slack-channel-members`
- **Type:** `template`
- **Revision:** 3
- **Image:** Default task image.

**Parameters**

| Label | Name | Type | Required | Default | Helper text |
| --- | --- | --- | --- | --- | --- |
| Authentication API Token | `token` | Secured | Yes | `$(workspace.params.slack-token)` | The token is associated with the slack application |
| Channel | `channel` | Text | Yes |  | Conversation ID to learn more about |

**Results**

| Name | Description |
| --- | --- |
| `response` | The list of the channel's member ids |

## Get Slack Channels

Retrieves the Slack channels using a Slack application through Bot tokens. For further reading on the underlying API see https://api.slack.com/methods/conversations.list

- **Slug:** `get-slack-channels`
- **Type:** `template`
- **Revision:** 3
- **Image:** Default task image.

**Parameters**

| Label | Name | Type | Required | Default | Helper text |
| --- | --- | --- | --- | --- | --- |
| Authentication API Token | `token` | Secured | Yes | `$(workspace.params.slack-token)` | The token is associated with the slack application |
| Team | `team` | Text | No |  | Encoded team id to list channels in |
| Channel Types | `types` | Select | No |  | Channel types: private, public, mpim, im |

**Results**

| Name | Description |
| --- | --- |
| `response` | List of limited channel-like conversation objects |

## Invite Members to Channel

Invite Slack users to a conversation using a Slack application through Bot tokens. For further reading on the underlying API see https://api.slack.com/methods/conversations.invite

- **Slug:** `invite-members-to-channel`
- **Type:** `template`
- **Revision:** 3
- **Image:** Default task image.

**Parameters**

| Label | Name | Type | Required | Default | Helper text |
| --- | --- | --- | --- | --- | --- |
| Authentication API Token | `token` | Secured | Yes | `$(workspace.params.slack-token)` | The token is associated with the slack application |
| Channel | `channel` | Text | Yes |  | The ID of the channel to invite user(s) to |
| Users | `users` | Text | Yes |  | A comma separated list of user IDs |

**Results**

| Name | Description |
| --- | --- |
| `response` | Details of the extended invitation |

## Remove Member from Channel

Removes a user from Slack conversation using a Slack application through Bot tokens. For further reading on the underlying API see https://api.slack.com/methods/conversations.kick

- **Slug:** `remove-member-from-channel`
- **Type:** `template`
- **Revision:** 3
- **Image:** Default task image.

**Parameters**

| Label | Name | Type | Required | Default | Helper text |
| --- | --- | --- | --- | --- | --- |
| Authentication API Token | `token` | Secured | Yes | `$(workspace.params.slack-token)` | The token is associated with the slack application |
| Channel | `channel` | Text | Yes |  | ID of conversation to remove user from. |
| User | `user` | Text | Yes |  | User ID to be removed |

**Results**

| Name | Description |
| --- | --- |
| `response` | The result of the removal action |

## Send Custom Slack Message

Send custom JSON payload to a specified Slack webhook URL. For more information on the underlying Slack API and potential configurations: https://api.slack.com/messaging/webhooks

- **Slug:** `send-custom-slack-message`
- **Type:** `template`
- **Revision:** 2
- **Image:** Default task image.

**Parameters**

| Label | Name | Type | Required | Default | Helper text |
| --- | --- | --- | --- | --- | --- |
| URL | `url` | Secured | No |  |  |
| Message Payload | `message` | Text Editor | No |  |  |

No results.

### Example

Post to a Slack channel through an incoming webhook when a build is ready.

| Field | Value |
| --- | --- |
| **Task name** | `notify` |
| **URL** | `$(workspace.params.slack-webhook-url)`, a secured workspace parameter that holds the webhook's URL |
| **Message Payload** | The payload below |

**Message Payload**

```json
{
  "text": "Build $(params.version) is ready",
  "blocks": [
    {
      "type": "section",
      "text": { "type": "mrkdwn", "text": "*Build $(params.version)* is ready for review." }
    }
  ]
}
```

The task posts the payload, as written, to the webhook, which posts to the channel it was created for. It returns no results. On the default task image, `boomerangio/task-flow:3.3.0`, Send Simple Slack Message and Send Slack Message with File Contents send nothing, so use this task for webhook messages, or move to `boomerangio/task-flow:3.4.0`.

### Common problems

| Symptom | Cause | Fix |
| --- | --- | --- |
| The task succeeds, but nothing reaches Slack, and the log shows an error such as `Error: An HTTP protocol error occurred: statusCode = 404` | The task doesn't fail when Slack refuses the message or can't be reached: it logs the error and ends **Succeeded**. A 400 means Slack rejected the payload; a 403 or 404, that the webhook URL is wrong, revoked or turned off. | After a first run, check **View Log** on the task, and fix the payload or the URL. |
| The task succeeds, but the log shows `SyntaxError` and `is not valid JSON` | **Message Payload** isn't valid JSON. A reference inserts its value as written, so a quote or line break in the value breaks the JSON. | Correct the payload, and keep values that can hold quotes or line breaks out of it. |
| The task fails with `URL has not been set` | **URL** is blank. | Enter the webhook's URL, or a reference to a secured parameter that holds it. |

## Send Simple Slack Message

Easily configurable slack webhook message. To provide additional parameters, please see our Custom Slack Message task.

- **Slug:** `send-simple-slack-message`
- **Type:** `template`
- **Revision:** 2
- **Image:** Default task image.

> [!WARNING]
> Every revision sends nothing and ends `succeeded` on `boomerangio/task-flow:3.3.0`, the default task image: the task stops with `ReferenceError: datetime is not defined` in its log before it calls Slack. Send Custom Slack Message posts to the same kind of incoming webhook. Fixed in task-flow 3.4.0: set Default Image Path to `boomerangio/task-flow:3.4.0`.

**Parameters**

| Label | Name | Type | Required | Default | Helper text |
| --- | --- | --- | --- | --- | --- |
| Webhook URL | `url` | Secured | No |  |  |
| Channel | `channel` | Text | No |  |  |
| Icon | `icon` | Text | No |  |  |
| Username | `username` | Text | No |  | Name displayed as the sender of the slack message |
| Message | `message` | Text Area | No |  |  |

No results.

## Send Slack Message with File Contents

Send slack message with file contents via webhook

- **Slug:** `send-slack-message-with-file-contents`
- **Type:** `template`
- **Revision:** 2
- **Image:** Default task image.

> [!WARNING]
> Every revision sends nothing and ends `succeeded` on `boomerangio/task-flow:3.3.0`, the default task image: the task stops with `ReferenceError: datetime is not defined` in its log before it calls Slack. Send Custom Slack Message posts to the same kind of incoming webhook. Fixed in task-flow 3.4.0: set Default Image Path to `boomerangio/task-flow:3.4.0`.

**Parameters**

| Label | Name | Type | Required | Default | Helper text |
| --- | --- | --- | --- | --- | --- |
| Webhook URL | `url` | Secured | No |  |  |
| Channel | `channel` | Text | No |  |  |
| Icon | `icon` | Text | No |  |  |
| Username | `username` | Text | No |  | Name displayed as the sender of the slack message |
| Message | `message` | Text Area | No |  |  |
| File Content | `content` | Text Area | No |  |  |
| Decode File Content | `encoded` | Boolean | No | `false` |  |
| Context | `context` | Text | No |  |  |

No results.

## Upload Slack File with Message

Upload a message to Slack using a Slack application through Bot tokens. For further reading on the underlying API see https://api.slack.com/methods/files.upload

- **Slug:** `upload-slack-file-with-message`
- **Type:** `template`
- **Revision:** 4
- **Image:** Default task image.

> [!WARNING]
> Every revision calls a Slack method that Slack has retired, so the task fails. To post text through an incoming webhook, use Send Custom Slack Message. See [Upload Slack File with Message fails](https://www.useboomerang.io/docs/flow/main/introduction/known-issues#upload-slack-file-with-message-fails).

**Parameters**

| Label | Name | Type | Required | Default | Helper text |
| --- | --- | --- | --- | --- | --- |
| Token | `token` | Secured | No | `$(workspace.params.slack-token)` |  |
| Channel | `channel` | Text | No |  |  |
| Message | `message` | Text Area | No |  |  |
| File Name | `fileName` | Text | No |  | Filename of file. |
| File Content | `fileContent` | Text Area | No |  | File contents via a POST variable |
| Decode File Content | `encoded` | Boolean | No | `false` |  |
| File Path | `filePath` | Text | No |  | Full path to desired file |
| File Title | `fileTitle` | Text | No |  | Title of file. |

No results.
