Files
oam/knowledge base/slack.md
2025-04-10 21:17:20 +02:00

5.1 KiB

Slack

  1. TL;DR
  2. Add custom emoji
  3. Give aliases to existing emojis
  4. Use incoming webhooks for notifications
  5. Use bots for notifications
  6. Create apps
  7. Further readings
    1. Sources

TL;DR

Setup
brew install --cask 'slack'
mas install '803453959'

CLI:

brew install --cask 'slack-cli' \
&& slack login

Authorization data will be saved to ~/.slack/credentials.json.

Usage
# Login.
slack login

# List authorized accounts.
slack auth list
slack list
# Send notifications to channels using the APIs.
curl --request 'POST' --url 'https://slack.com/api/chat.postMessage?pretty=1' \
  --header 'Authorization: Bearer xoxb-012345678901-0123456789012-abcdefghijklmnopqrstuvwx' \
  --header 'Content-type: application/json' --data '{"channel": "C04K1234567", "text": "Hello, World!"}'

# Send notifications to channels using incoming webhooks.
curl --request 'POST' --url 'https://hooks.slack.com/services/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' \
  --header 'Content-type: application/json' --data '{"text": "Hello, World!"}'

Add custom emoji

Check out slackmojis for some common reactions.

  1. Go to https://{{org-name}}.slack.com/customize/emoji.
  2. Select Add Custom Emoji.
  3. Upload the image. Supported formats: GIF, JPG, PNG.
  4. Give it a name.

Give aliases to existing emojis

  1. Go to https://{{org-name}}.slack.com/customize/emoji.
  2. Select Add Alias.
  3. Choose the image.
  4. Give it an alias.

Use incoming webhooks for notifications

Refer Sending messages using incoming webhooks and Setting Up Slack Webhook URL Simplified 101.

  1. Enable Incoming Webhooks for a Slack app.
    FeaturesIncoming WebhooksActivate Incoming Webhooks.

  2. Create a new Webhook URL and authorize it (or request authorization for it).

  3. Install (or request an higher entity to install) the app in the workspace.
    App details → SettingsInstall AppOAuth Tokens.

  4. Send a test request to the webhook:

    curl --request 'POST' --url 'https://hooks.slack.com/services/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' \
      --header 'Content-type: application/json' --data '{"text": "Hello, World!"}'
    

Use bots for notifications

Refer Automating Slack Notifications: Sending Messages as a Bot with Python.

  1. Create a new Slack App.

  2. Select From Scratch.

  3. Enter a name (e.g., test bot) and select a workspace for it.

  4. Add the required OAuth scopes (e.g. chat:write).
    App details → FeaturesOAuth & PermissionsScopesBot Token Scopes.

  5. Install (or request an higher entity to install) the app in the workspace.
    App details → SettingsInstall AppOAuth Tokens.
    This will automatically generate an OAuth token for the app. Note that token down.

  6. Add the app to the channels it needs to interact with. Channel details → Integrations tab → Apps section → Add apps.

  7. Try sending messages using the app's OAuth token:

    curl --request 'POST' --url 'https://slack.com/api/chat.postMessage?pretty=1' \
      --header 'Authorization: Bearer xoxb-012345678901-0123456789012-abcdefghijklmnopqrstuvwx' \
      --header 'Content-type: application/json' --data '{"channel": "C04K1234567", "text": "Hello, World!"}'
    

Create apps

Direct link.

Further readings

Sources