Ce howto décrit comment configurer le fournisseur Slack inclus dans discourse-chat-integration.
Il permet de publier des notifications sur Slack, de gérer des règles à l’aide de commandes Slash et de publier des transcriptions vers Discourse. Les instructions pour les commandes Slash se trouvent en tapant /discourse help. La transcription peut être créée à l’aide des menus contextuels sur les messages Slack.
Installation
Si ce n’est pas déjà fait, installez le plugin discourse-chat-integration, et assurez-vous qu’il est activé via le paramètre du site chat integration enabled.
Configuration de Slack
Rendez-vous sur Slack API: Applications | Slack et créez une nouvelle application. Si vous n’êtes pas déjà connecté, vous serez invité à le faire. (vous devrez peut-être cliquer à nouveau sur ce lien, car il ne semble pas rediriger après la connexion )
Cliquez sur Create New App
Choisissez un nom (peut être n’importe quoi) et sélectionnez l’équipe Slack dont vous souhaitez qu’elle fasse partie
Dans le menu de gauche, sous “Features”, cliquez sur “OAuth & Permissions”.
Faites défiler jusqu’à “Scopes / Bot Token Scopes” et ajoutez chacun des éléments suivants pour permettre au plugin de publier des messages dans votre espace de travail Slack :
chat:write
chat:write.customize
Allez à la page Settings > Install App (Installer l’application), cliquez sur Install to Workspace (Installer dans l’espace de travail) et autorisez l’application avec votre équipe
Copiez le Bot User OAuth Token, et collez-le dans les paramètres de votre site Discourse sous chat_integration_slack_access_token
Allez à la page Basic Information (Informations de base), copiez le Verification Token, et collez-le dans les paramètres de votre site Discourse sous chat_integration_slack_incoming_webhook_token
En bas de la page Basic Information, vous pouvez définir l’icône, le nom et la description de votre bot.
Configurez des “Règles” pour vos canaux, conformément aux instructions de discourse-chat-integration, ou utilisez alternativement les commandes slash dans un canal pour commencer.
Ajoutez l’utilisateur bot Discourse aux canaux auxquels vous souhaitez qu’il puisse publier :
Depuis le menu de gauche de la page de votre client Slack, faites un clic droit sur le nom du canal auquel vous souhaitez ajouter l’application et cliquez sur View Channel Details (Voir les détails du canal) :
Il est probable que cela soit dû à une erreur de configuration. Vérifiez que la valeur que vous avez configurée pour Request URL est correcte. Elle doit être sous cette forme :
I’m very excited to try this plugin. I gave installing it a shot by following these instructions carefully, but when I go to test a slash command on slack I get:
slackbot Darn - that slash command didn't work (error message: `403_client_error`). Manage the command at Discourse Integration.
This would suggest that it’s an issue with the authentication of slack to your Discourse instance. Can you double check that the incoming webhook token has been copied across correctly? (step 12 above) Make sure there’s nothing weird being copied before/after (e.g. spaces)
Ugh, I went through the instructions twice, and realized I copied the verification token incorrectly. My issue was completely PEBKAC :(- thanks for the (immediate) help!
New rule:/discourse [watch|follow|mute] [category] [tag:name]
(you must specify a rule type and at least one category or tag)
watch – notify this channel for new topics and new replies
follow – notify this channel for new topics
mute – block notifications to this channel
The integration doesn’t seem to be able to find tags. edit: Ugh… I just saw the docs that the syntax for tags is [tag:name] … sorry I missed that…
I noticed that the help files are hard coded to the slash command “/discourse”… I pulled down the source and got as far as finding the strings in the locale files and where they’re invoked in the helper. I would like to issue a PR to allow the slash command in help files to be configurable (my integration uses my sitename as the command…) but I’m not sure how persistence works with Discourse plugins. If I submitted a partially complete PR would you be able to provide some pointers or would that be a waste of time ?
Also, where would be the best place to add feature requests ?
The easiest way to change this to a different command is to go to your discourse admin panel, CustomizeText Content, then type chat_integration.provider.slack into the search bar. You’ll find the “help” string in this list. Changes to this should persist across discourse/plugin updates
I think slack-specific ones in this topic, and general ones for the plugin in the main topic
You need to use the “OAUTH Token” method of authentication to slack, not the “Webhook” method. The instructions above should walk you through setting up the oauth method.
That did it. I think I broke it by foolishly trying to migrate the settings from the other slack plugin.
One thing I don’t understand is who can use the slack App I created. It is just me? If so, that’s a little sucky. If not, wait, anyone can control what categories get watched? I see “collaborators” in the slack API page. If I add a collaborator can they too control the rules?
Also, it seems that rules established in the Discourse web interface don’t show up in slack if you do a /discourse status. Is that right?
When you create slack apps, they are private to you. Only you can edit the settings of the app, and only you can install it onto an organisation. Notice the “Not Distributed” status:
You can then install your app onto your Slack organisation. If you have slash commands set up, anyone in that organisation can control the ‘rules’ for any channel they have access to, and so you should make sure to set the chat integration discourse username appropriately.
‘Collaborators’ of the Slack app means that they can edit the app’s settings (things like callback URLs, auth secrets etc.). It has absolutely nothing to do with who can configure ‘rules’ using slash commands.
/discourse status should list all of the rules for the current channel. So if you have set up rules for #general using the discourse admin interface, they should show up when you run /discourse status in #general. If that’s not working, it’s a bug.
Thanks, @david, that’s a huge help. It still seems a bit wild that any slack user can change what Discourse stuff gets posted to a channel, but I suspect that’s because I don’t understand slack.
I think it depends what kind of community you have in Slack. In my mind there are three main scenarios:
If any member of the public can join your Slack organisation, Slash commands probably aren’t a good idea. In this case it’s probably easiest to just manage the rules from the discourse admin panel.
If you have a fairly open forum, but a closed slack organisation (like I believe the discourse team do), then having slash commands is a nice convenience without any real issue (everyone in slack is trusted).
If you have a roughly 1:1 mapping between forum members and slack members (e.g. a corporate environment), it can be useful to allow individuals to manage the rules in their own slack channel. For example, the dev team might want to watch dev, and the support team support. Rather than forcing all this to be done by a discourse admin, they can do it themselves with slash commands. I think this is how @mcwumbly uses slack integration.
We’re starting to see some healthy adoption of Slack threads in some channels. I was a big skeptic at first, but as people find good patterns for using them, I can see their value. Does the transcript feature work with threads at all?
Should transcript export work with Direct Messages? I just tried with two different ones and it’ll say Loading the transcript... but nothing happens after that.