Allow Slack to unfurl/expand links to "login-required" Discourse instance

I reached out to the Slack folks with this request and got the following reply.

My request:

We have private Slack and Discourse instances and I’m looking for ways to better integrate the two. We also use Google Apps extensively.

It’d be awesome if there were a way to configure Slack with credentials to retrieve content from these other applications and unfurl/expand them accordingly.

I searched and haven’t found any way to do this yet. Is it already possible? If not, is this a request that could be considered in the future?

Thanks!

Their reply:

Thanks for taking the time to write in! A better standard for custom unfurling of private content is something we’re indeed looking to offer further down the road.

For now, we’d recommend you start by creating a Slack app, since we already have features that will get you close to what you’re looking for:

Introduction to Slack apps | Slack

OAuth would allow teams who’ve added your app to send an authenticated request from Slack to your service (triggered by the posting of your private links).

You can use a outgoing webhook or bot to listen for these links, retrieve the relevant content, then send it back in a payload to the team as a workaround to offer this content.

I hope this suggestion helps you get started, and please let us know if there’s anything else we can help with!

Regards,
Tuan

5 Likes

I’m going to investigate working on this because I think it would add a ton of value to our private instance.

Here’s what I’m thinking:

  1. In Slack Configure an outgoing web hook in slack
    • trigger_word=myforum.domain.com
    • token=someToken
    • URLs=https://myforum.com/slackdoor/
    • text=the original chat message body that includes myforum.domain.com in there
  2. In Discourse Add /slackdoor endpoint to Discourse
    • site_setting:slackdoor_token=someToken
    • check that requestbody.token=site_setting.slackdoor_token
    • parse requestbody.text field for URL
    • retrieve post data from the post associated with the URL
    • respond with a rich body compatible with slacks message attachment api

Is part (2) of this plugin territory? Or something that belongs in core? (Or has anyone done something like this already that I haven’t seen yet).

I’ve got a basic implementation of this working along the line of what I posted above…

I will post a proper plugin topic and readme in the next day or so.

If anyone has any feedback in the mean time, please let me know:

https://github.com/mcwumbly/discourse-slackdoor

1 Like

Would it make sense to bake this into the Slack Notification plugin by @bernd?

Maybe, I’m not sure yet. At the moment, I need this feature and not what that other plugin has to offer. I imagine the reverse may be true too.

@sam if you have a few minutes to take a look at the direction this one is headed, I’d love a sanity check on how some of the authentication stuff is being overridden…

The canonical plugin topic is now here: Discourse Slackdoor Plugin

3 Likes