Set up Slack notifications using the discourse-chat-integration plugin

Discourse
Mon, 24 Jul 2017 16:45:28 +0000
Integrations

This howto describes how to setup the Slack provider included in discourse-chat-integration.

It allows posting notifications to Slack, managing rules using Slash Commands, and posting transcripts back to Discourse. Slash command instructions can be found by typing /discourse help. Transcript can be created using the context menus on Slack posts.

Install

If you haven’t already, install the discourse-chat-integration plugin, and make sure its enabled via the chat integration enabled site setting.

Setup Slack

1. Head over to Slack API: Applications | Slack and create a new app. If you’re not already logged in, you’ll be prompted to do so. (you may need to click on this link again, as it doesn’t seem to redirect after login )

2. Click Create New App

3. Choose a name (can be anything), and select the Slack Team you want it to be a part of

4. In the left-hand menu, under “Features”, click “OAuth & Permissions”.

5. Scroll down to “Scopes / Bot Token Scopes”, and add each of these to enable the plugin to post messages to your Slack workspace:

chat:write

chat:write.customize

For slash commands and transcript posting (If you don’t need this, skip this block)

6. Add the following scopes under “Scopes / Bot Token Scopes”

users:read

channels:history

groups:history

im:history

7. On the left-hand menu, under “Features”, go to the Slash Commands page. Click Create New Command

Command - /discourse

Request URL - <your-discourse-url>/chat-integration/slack/command

Short Description - Manage this channel's integration with Discourse

Usage Hint - [watch|thread|follow|mute|remove|status|post|help]

Note: if you choose to use a slash command other than /discourse (e.g. choosing a command to match your site name), you can adjust the help text to reflect the command on your Discourse admin panel. Customize → Text Content → search for the following settings and change /discourse to match your command:

“chat_integration.provider.slack.help”

“chat_integration.provider.slack.status.no_rules”

“chat_integration.provider.slack.parse_error”

“chat_integration.provider.slack.delete.error”

8. Save

9. Go to the Interactivity & Shortcuts page, enable the Interactivity section by switching it to On and enter this url under “Request URL”

<your-discourse-url>/chat-integration/slack/interactive

10. Save Changes

11. Go to the Interactivity & Shortcuts page, click Create new Shortcut, choose “On messages”, and click Next. Enter these details:

Name: “Post to Discourse” (feel free to change)

Short description: “Create a transcript to post on Discourse” (feel free to change)

Callback ID: post_shortcut (do not change)

12. Go to the Settings > Install App page, click Install to Workspace, and authorise the app with your team

13. Copy the Bot User OAuth Token, and paste it into your Discourse site settings under chat_integration_slack_access_token

14. Go to the Basic Information page, copy the Verification Token, and paste it into your Discourse site settings under chat_integration_slack_incoming_webhook_token

15. At the bottom of the Basic Information page, you can set your bot’s icon, name and description.

16. Setup some “Rules” for your channels, according to the discourse-chat-integration instructions, or alternatively use the slash commands within a channel to get started.

17. Add the Discourse bot user to the channels you want it to be able to post to:

From the left-hand menu of your Slack client page, right click the channel name you’d like to add the app to and click View Channel Details:

From the pop-up window, select the Integrations tab

On the Integrations page, you can click Add an App and choose the Discourse Bot:

The app should now be able to post to the channel

Upgrading to ‘Granular Scopes’

If you set up your integration a while ago, you may need to upgrade to Slack’s “Granular Scopes” for things to work as described above.
Instructions (clicca per ulteriori dettagli)

Troubleshooting

/discourse slash command returns dispatch_failed error

Symptom

After configuring Slack integration, you try the /discourse slash command and see the following error in Slack:

/discourse failed with the error "dispatch_failed"

Cause

It’s likely that this is due to a configuration error. Verify that the value you have configured for Request URL is correct. It should be in this form:

<your-discourse-url>/chat-integration/slack/command

Fix

Update your Request URL and pay particular attention to the following:

1. Ensure it begins with the correct protocol (e.g. https://)

2. Ensure it is using the domain for your Discourse site (not your Slack instance)

3. Ensure it has the correct path /chat-integration/slack/command

Last edited by @JammyDodger Sunday, May 26, 2024 7:10 AM UTC
Check document (clicca per ulteriori dettagli)

106 messaggi - 44 partecipanti