Post to Slack Channel

I have not found anything in the actions directory, has anyone ever found a way to post text from Drafts to a Slack channel?

Editing to add: Right now I just have an action that copies the draft text, and runs a shortcut that opens Slack to a place where I can choose channel/person. Once I do that I just paste.

You can go to Slack API: Applications | Slack and create a new app. Then create an Incoming Webhook for the channel you want to post to, which will generate a URL. Then you can POST to that URL using the Drafts

let http = HTTP.create();

let response = http.request({
  "url": "https://hooks.slack.com/services/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",
  "method": "POST",
  "data": {
    "text":"Hello from Drafts!"
  },
  "headers": {
    "HeaderName": "HeaderValue"
  }
});

if (response.success) {
  var text = response.responseText;
  var data = response.responseData;
}
else {
  console.log(response.statusCode);
  console.log(response.error);
}
2 Likes

Thank you! Will be doing this tomorrow morning.

1 Like