Skip to content

Instantly share code, notes, and snippets.

@chdsbd
Created September 16, 2018 04:15
Show Gist options
  • Save chdsbd/ced53549cceed7fa881d32b5ebeac919 to your computer and use it in GitHub Desktop.
Save chdsbd/ced53549cceed7fa881d32b5ebeac919 to your computer and use it in GitHub Desktop.
Disable Slack notifications for the weekend

Disable Slack notifications for the weekend

There isn't a way to configure DND for the weekend on Slack. However, you can use the /dnd 24 hours command to disable notifications for 24 hours using the undocumented API and legacy tokens. We're going to use the undocumented api and IFTTT to automate this.

Steps

  1. Generate a token for your account
  2. Navigate to your personal DM and copy the url (e.g. DAYM93S0N from acme.slack.com/messages/DAYM93S0N/convo/GBG661YR2-1536698414.000100/)
  3. Update the following url with your information (TOKEN looks like xoxp-4030334043-4959593942-3030320302032-sdf23rfasdf23rsf and CHANNEL looks like DAYM93S0N)
    https://slack.com/api/chat.command?token=xoxp-4030334043-4959593942-3030320302032-sdf23rfasdf23rsf&channel=DAYM93S0N&command=%2Fdnd&text=24%20hours
  4. You should have a url like this: https://slack.com/api/chat.command?token=xoxp-4030334043-4959593942-3030320302032-sdf23rfasdf23rsf&channel=DAYM93S0N&command=%2Fdnd&text=24%20hours
  5. Test your url like the following
    unset HISTFILE # don't want to store these credentials
    curl --request POST \
      --url "https://slack.com/api/chat.command?token=xoxp-4030334043-4959593942-3030320302032-sdf23rfasdf23rsf&channel=DAYM93S0N&command=%2Fdnd&text=24%20hours"
      
    # expected response
    # {"ok":true,"response":"All set. I\u2019ve turned on Do Not Disturb"}
  6. Create a new IFTTT applet with the "Date & Time" service that triggers "Every day of the week at" and check Saturday and Sunday. Create a "that" webhook that makes a request to the url we made with a "GET" method. Leave everything else blank.
  7. You're done. You should now have DND enabled automatically for the weekend.
@pablonm3
Copy link

thank you so much for this! great idea!

@nielsek
Copy link

nielsek commented Nov 16, 2019

Thanks! It's also possible to do &text=until%20Monday if you just want to send 1 request.

@k4mrul
Copy link

k4mrul commented Mar 17, 2020

Thank you! Still works great

@chdsbd
Copy link
Author

chdsbd commented Jul 10, 2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment