Slack Setup
Last updated
Last updated
To generate a Slack bot and obtain an API token, follow these steps:
Go to the Slack API website: https://api.slack.com/apps
Click on the "Create New App" button to create a new Slack app.
Provide a name for your app and select the Slack workspace where you want to install the app. Click on the "Create App" button.
Once your app is created, you'll be redirected to the app's settings page. In the left sidebar, under "Settings," click on "OAuth & Permissions".
Scroll down to the "Scopes" section and locate the "Bot Token Scopes" section. Here, you can specify the permissions and access levels your bot will have. Select the required scopes based on the functionality you need for your bot.
Add the following permissions: i. chat:write ii. channels:read iii. groups:read iv. mpim:read v. im:read
After selecting the necessary scopes, scroll back up to the top of the page and click on the "Install App" menu under the "Settings" menu in the left sidebar.
Review the permissions requested by your app and click on the "Allow" button to install the app in your workspace.
Once installed, you will be redirected back to the app's settings page. Scroll down to the "OAuth Tokens & Redirect URLs" section. You will find your bot's API token under the "Bot User OAuth Token" field. This token is used to authenticate requests made on behalf of your bot.
Make sure to keep your API token secure, as it grants access to your bot and associated permissions.
That's it! You now have a Slack bot and its corresponding API token. You can use this token to authenticate your bot's HTTP requests and interact with the Slack API.
Create a new channel or open an already create channel. This is the channel the bot will be sending all notifications to.
On the channel page, right click the channel and click the "View channel details" menu
On the channel details modal, click on the integration tab.
On the integration tab, scroll to "Apps" section, then click on "Add apps" button
You will be redirect to page with list of all created apps, search for the name you create from the step above. Click on "add" button beside the name.
Then close the modal by click the "x" at the top of the page.
Now the bot/app is added to the channel, you can then proceed to the next steps below
To obtain the Slack Channel ID, you can follow these steps:
Open Slack and navigate to the workspace where the channel is located.
Right-click on the channel name in the left sidebar.
From the context menu that appears, select "Copy Link" or "Copy Link Address" (the exact option may vary depending on your operating system and browser).
Paste the copied link into a text editor or any other suitable location.
Look for a section in the link that resembles C12345678
. The alphanumeric code starting with the "C" is the Channel ID.
Alternatively, you can also retrieve the Channel ID programmatically using the Slack API. Here's an example using cURL:
Replace YOUR_API_TOKEN
with your actual API token. This request will retrieve a list of channels and conversations in your workspace, along with their corresponding IDs. Look for the specific channel you're interested in and note down its ID.
Remember that your API token needs the necessary permissions (e.g., channels:read
) to access this information.
By following either of these methods, you can obtain the Channel ID of a Slack channel.