Thoughts, stories and ideas for web developers (with a focus on WordPress)

The popular community software Discourse has some awesome official plugins, including a plugin that makes it possible to share new Discourse topics in a specific Discord channel.

I'm currently in the process of trying to migrate most members of my Discord channel to a new forum I set up with Discourse. One of the best ways to do this, is to automatically share a link to new topics in the existing Discord server, so the Discord community can become familiar with the Discourse forum.

Fortunately, it's also pretty easy to automate this through the official Discourse Chat Integration plugin.

Installing the plugin

You install the plugin just like any other Discourse plugin. When that's done, go to the admin interface of your Discourse setup, choose 'Plugins' and browse to the discourse-chat-integration settings page.

Make sure you checked the option Chat integration enabled.

Changing the username

The first thing you should do is think about security. I'll be setting up a bot that will share all new topics of my forum in a public Discord channel. However, I don't want to share topics in locked crew-only categories! That's why it's a good idea to create a new Discourse user and give it access to only the necessary categories. So in my case, I just created a simple default Discourse user that has access to all the public categories.

Enter the username of the new user in chat integration discourse username.

Scroll down a bit and make sure to enable the checkbox Enable the Discord chat-integration provider.

Creating a Discord webhook

This seems like a lot of work, but is actually a very easy step. Open your Discord server and browse to the server settings. Go to Apps > Integrations and choose "Webhooks".

Create a new webhook. Customizing the avatar and name is optional, but make sure to choose the right channel. This is where your bot will post messages. When that's done, just copy your webhook link.

Setting up the integration

With the webhook link in your clipboard, go back to the Discourse admin page and choose "Plugins". A new navigation menu will appear. Choose 'Chat Integrations' and click on 'Discord'.

Click on 'Create a new channel'. Give the channel a name (this is just for your own reference, it doesn't really matter) and paste the webhook URL.

This wraps up the connection between Discourse and Discord. Neat! Make sure to try it out with the 'Test' button. A new Discord message should appear in the designated channel.

Creating a rule

Now we just need to tell the bot when a new Discourse message should be created. Choose 'Create rule'. Since I just want to push new (public) topics to a Discord channel, I'll configure my settings like this:

  • Type: Normal
  • Filter: First post only
  • Category: All categories (we're already limiting access by using a different user account instead of the default system user)

Save the rule and you're done!

Updating the message text

If you want to change the default text for the message, just go to Admin > Customize > Text and search for the text.

You’ve successfully subscribed to Teebow Blogs
Welcome back! You’ve successfully signed in.
Great! You’ve successfully signed up.
Success! Your email is updated.
Your link has expired
Success! Check your email for magic link to sign-in.