# Slack

Slack is a messaging application designed for businesses that enables individuals to access the information they require. By uniting people to function as a cohesive team, Slack revolutionizes the way organizations communicate.

### Setting up a new Slack connection

1. Head to this [link](https://api.slack.com/apps) and click on **Create New App > From scratch**\
   ![](https://2212031742-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXyVsBiX9OwOL1o9g5hLM%2Fuploads%2FhGSn1KhoZyOLrRItRDsN%2Fimage.png?alt=media\&token=be19edc1-592a-4bf4-9f37-90152d6300a1)
2. Enter your app name and select your slack workspace.
3. Then click on **Create App**
4. Go to **OAuth & Permissions** page.\
   &#x20;![](https://2212031742-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXyVsBiX9OwOL1o9g5hLM%2Fuploads%2FucI6rG3SVwUKbrpQu9zt%2Fimage.png?alt=media\&token=b9bee566-6605-4bf0-be37-bb609474576c)
5. Copy **OAuth Redirect URL** from Plumber and add it in Redirect URL. Click on **Save URLs.**\
   ![](https://2212031742-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXyVsBiX9OwOL1o9g5hLM%2Fuploads%2FdDwJTvgFbtviVOaZBPLt%2Fimage.png?alt=media\&token=3029b5be-db99-457f-bb0b-1e7726fcfb42)
6. Go to **Bot Token Scopes** and add `chat:write.customize` along with `chat:write` scope to enable the bot functionality.\
   ![](https://2212031742-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXyVsBiX9OwOL1o9g5hLM%2Fuploads%2FZD3Y7vQIRFbFgtncyd8W%2Fimage.png?alt=media\&token=8a4923b0-4270-42eb-bf0e-8e937ff58dff)
7. Go back to **Basic Information** on the left sidebar.
8. Scroll down to **App Credentials**.&#x20;
   * Copy **Client ID** into the **API Key** field in Plumber
   * Copy **Client Secret** into the **API Secret** field in Plumber

     <figure><img src="https://2212031742-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXyVsBiX9OwOL1o9g5hLM%2Fuploads%2F2wrbFniaxqzduoVZrNC3%2Fslack-connection.png?alt=media&#x26;token=85a090e1-1bdf-42b4-bc22-76db00a29180" alt=""><figcaption></figcaption></figure>
9. Click on **Connect.**
10. A new window with the Slack consent screen will pop up.&#x20;

{% hint style="info" %}
If a new window does not appear, it could because your Slack organisation does not allowing adding this new Slack app. Ask your Slack admin to approve this.
{% endhint %}

11. Click on **Allow**.\
    ![](https://2212031742-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXyVsBiX9OwOL1o9g5hLM%2Fuploads%2FZqlkcME733ycjWSLPzbX%2Fimage.png?alt=media\&token=13d7f699-db9e-4e1b-89e5-fc6b52e45407)
12. Your **Slack** integration is now ready!

### Send a message to a channel

<table><thead><tr><th>Field</th><th width="347.32421875">Description</th><th>Required</th></tr></thead><tbody><tr><td>Channel</td><td><p>Select the channel you want to send the message to. </p><p></p><p>If you do not find your channel in the dropdown list, ensure that the channel is Public or the user that your API token is created under has access to the channel. If you want to send to a private channel, see here.</p></td><td>✔️</td></tr><tr><td>Message </td><td><p>Message body of the message.</p><p></p><p> This supports whatever markdown syntax that Slack supports. <a href="https://docs.slack.dev/messaging/formatting-message-text/#basic-formatting">See how to format your message</a>.<br><br>To <a href="https://api.slack.com/reference/surfaces/formatting#mentioning-users"><strong>mention users</strong></a>, use the following format: &#x3C;@USER_ID>. e.g.:</p><p>Copy</p><pre><code>Hey &#x3C;@U024BE7LH>, thanks for submitting your report.
</code></pre><p>To get the user's ID, click on the overflow button in their Slack profile, and choosing the <code>Copy member ID</code> option.</p><p>To <a href="https://api.slack.com/reference/surfaces/formatting#mentioning-groups"><strong>mention user groups</strong></a>, use the following format: &#x3C;!subteam^ID>, e.g.:</p><p>Copy</p><pre><code>Hey &#x3C;!subteam^SAZ94GDB8>, there's a new task in your queue.
</code></pre></td><td>✔️</td></tr><tr><td>Send as a bot?</td><td><p>If <code>false</code>, the message will be sent as yourself. </p><div><figure><img src="https://2212031742-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXyVsBiX9OwOL1o9g5hLM%2Fuploads%2FtLYgmnvdGpcVxpfk4Oj4%2Fimage.png?alt=media&#x26;token=f0f559a9-699f-4c30-af4b-bd1114d5c9ce" alt="" width="350"><figcaption><p>The first message is sent with <code>Send as a bot?</code> set to false. The next is set to true.</p></figcaption></figure></div></td><td>Defaults to <strong>No</strong></td></tr><tr><td>Bot name</td><td><p><em>Only works if Yes is selected for Send as a bot?</em> </p><p>Sender name of the bot.</p></td><td></td></tr><tr><td>Bot icon</td><td><p><em>Only works if Yes is selected for Send as a bot?</em> </p><p>Display image of the bot. This can be:</p><ul><li> an emoji that your Slack org supports such as <code>:robot:</code> 🤖 </li><li>a URL pointing to the image</li></ul></td><td></td></tr></tbody></table>

### Find a message

This action looks for a message in your Slack org.

<table><thead><tr><th>Field</th><th width="348.71484375">Description</th><th>Required</th></tr></thead><tbody><tr><td>Search Query</td><td><p>Search query to use for finding matching messages. <br></p><p>Examples:<br><code>hello world</code> -> search term</p><p><code>in:#plumber hello world</code> -> search for the term in #plumber channel<br><code>in:#plumber-dev from:@ian hello world</code> -> search for the term in #plumber channel and sent by ian</p><p></p><p>See the <a href="https://slack.com/intl/en-gb/help/articles/202528808-Search-in-Slack">Slack Search Documentatio</a>n for more information on constructing a query.</p></td><td>✔️</td></tr><tr><td>Sort by </td><td>Options:<br>- <strong>Match strength</strong>: relevance to search query<br>- <strong>Message date time</strong>: date and time the message was sent</td><td>Defaults to <strong>Match strength</strong></td></tr><tr><td>Sort direction</td><td>Options:<br>- <strong>Descending</strong>: newest or best match<br>- <strong>Ascending</strong>: oldest or worst match</td><td>Defaults to <strong>Descending</strong></td></tr></tbody></table>

## FAQ

<details>

<summary>How to send a message to a private channel?</summary>

To send to private channels, you would need the Slack ID of the private channel (it will not appear in the dropdown). To retrieve this:&#x20;

1. start by typing `/display ids` into any conversation on Slack.
2. Select the built-in shortcut `Display IDs`

   <figure><img src="https://2212031742-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXyVsBiX9OwOL1o9g5hLM%2Fuploads%2FxyBliopVUmDpoNj7By0b%2FScreenshot%202024-02-06%20at%209.07.23%E2%80%AFPM.png?alt=media&#x26;token=0fdcda6d-15ee-461f-98df-9f3424d86636" alt=""><figcaption></figcaption></figure>
3. Select the private channel in the dropdown as shown in the screenshot below. ![](https://2212031742-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXyVsBiX9OwOL1o9g5hLM%2Fuploads%2FFmdjrEdfty0XoV2T7Xyy%2Fslack%20id%20selector.png?alt=media\&token=2391a3ad-a2e7-4e6c-b1d8-362203d4d2f5)
4. Copy and paste the selected conversation/channel ID into Plumber and click Use: \<CHANNEL\_ID>

   <figure><img src="https://2212031742-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXyVsBiX9OwOL1o9g5hLM%2Fuploads%2FmR9q0XxSKr6Uo1ldTcL7%2Fimage.png?alt=media&#x26;token=0a838548-06be-4fcb-b972-c57cf99e6ffe" alt=""><figcaption></figcaption></figure>

You can also manually retrieve a specific user group's ID by clicking `Copy group ID` in the overflow menu.

Ensure that you are not sending the message as a bot.

</details>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://guide.plumber.gov.sg/user-guides/actions/slack.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
