Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Slack webhook support #7

Closed
smashism opened this issue May 19, 2021 · 4 comments
Closed

Feature request: Slack webhook support #7

smashism opened this issue May 19, 2021 · 4 comments

Comments

@smashism
Copy link

Hi, it'd be really handy if there was an export that could post results via a Slack webhook into a channel (with flags for webhook URL, username, icon/emoji icon, etc.).

@ninxsoft
Copy link
Owner

ninxsoft commented May 22, 2021

💯 agree, Slack integration would be an awesome feature!

I haven't actually played with the Slack API, however after a quick scan of the docs it appears I can get away with the following config options:

{
  "name": "KMART Report",
  "url": "https://myorg.jamfcloud.com",
  "credentials": "base_64_encoded_username:password",
  "slack": {
    "enabled": true,
    "webhook_url": "https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX",
    "token": "xoxb-your-token",
    "channel": "channel_name",
    "text": "KMART Report has been generated!",
    "username": "username",
    "icon_url": "https://icon.url",
    "icon_emoji": ":white_check_mark:",
    "attachments": {
      "json": "filename.json",
      "plist": "filename.plist",
      "yaml": "filename.yaml",
      "markdown": "filename.md",
      "html": "filename.html"
    }
  }
}

If a webhook_url is empty or not specified, use the default Slack API endpoint (token, channel, etc.).

@smashism do you have a preference or specific use case for Webhooks over the standard Slack API ?

@smashism
Copy link
Author

I'd be fine with a webhook but I'm also a simple creature.

@ninxsoft
Copy link
Owner

ninxsoft commented Aug 22, 2021

Here's a screenshot of Slack successfully receiving KMART report file uploads:

Slack

Note: File Uploads are not possible via Webhooks, so instead the following fields are now required:

{
  "name": "KMART Report",
  "url": "https://myorg.jamfcloud.com",
  "credentials": "base_64_encoded_username:password",
  "slack": {
    "enabled": true,
    "token": "xoxb-your-token",
    "channel": "channel_name_or_id",
    "text": "Custom Slack message supporting Markdown and Emoji",
    "attachments": [
      "json",
      "plist",
      "yaml",
      "markdown",
      "html"
    ]
  }
}
  • A Bot Token will need to be created - Documentation
  • The Bot Token will require the chat:write and files:write scopes to be added - Documentation
  • Exclude any attachments you do not wish to upload

@ninxsoft
Copy link
Owner

Fixed in #11

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants