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

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

Enable

The discourse-chat-integration plugin is bundled with Discourse. No separate installation is required. To enable it, check that the chat_integration_enabled site setting is turned on.

Notifications

Set up Mattermost

Your Mattermost server needs to be accessible from your Discourse server in order to connect them. It is recommended that you use HTTPS, but HTTP should also work.

  1. In your Mattermost System Console, under Custom Integrations, check that these settings are enabled:

    • Enable Incoming Webhooks
    • Enable integrations to override usernames
    • Enable integrations to override profile picture icons
    • Enable Custom Slash Commands (if you want slash commands)
  2. Login to your team, click your name in the top left, then click Integrations

  3. Choose Incoming Webhooks, Add incoming Webhook

  4. Enter a “Display Name”, “Description”, and choose a random channel from the list (it doesn’t matter which one, Discourse will override this)

  1. Save

  2. Copy the URL provided, you’ll need it later

Setup Discourse

  1. Paste the URL you copied into the chat_integration_mattermost_webhook_url site setting

  2. Enable chat_integration_mattermost_enabled

  3. Setup some “Rules” for your channels, according to the discourse-chat-integration instructions. Channel identifiers look like #town-square or @davidtaylor.

  4. Click Test on one of the channels to check everything’s working. You should receive a message like this:

  5. :unicorn:

Slash Commands

Slash commands allow you to manage your rules from inside Mattermost. To get it working:

  1. If you didn’t already, enable Enable Custom Slash Commands in your Mattermost System Console

  2. Login to your team, click your name in the top left, then click Integrations

  3. Choose Slash Commands, Add slash command

    • Display Name: Discourse
    • Description: Manage Discourse notification rules
    • Command Trigger Word: discourse
    • Request URL: <your-discourse-url>/chat-integration/mattermost/command
    • Request Method: POST
    • Response Username: Discourse
    • Response Icon: (optionally specify an icon URL)
    • Autocomplete: :ballot_box_with_check:
    • Autocomplete Hint: Manage this channel's integration with Discourse
    • Autocomplete Description: [watch|follow|mute|delete|status|help]
  4. Save

  5. Copy the “Token” provided, and paste it into your Discourse site settings under chat_integration_mattermost_incoming_webhook_token

  6. Try sending /discourse help in your mattermost channel - you should get a message with a list of possible commands

  7. :1st_place_medal:

Last edited by @JammyDodger 2024-05-26T07:09:54Z

Check documentPerform check on document:
11 лайков

I recommend you also post this on the mattermost Discourse to get more feedbacks :cowboy_hat_face:

and probably a dedicated topic.

(also I wish we warned communities about hideous looking oneboxes cause they are missing images)

6 лайков

I think we already do in the dashboard if they use the default images for the logos.

1 лайк

Mattermost integration now supports slash commands (their implementation is built to be compatible with Slack’s) :tada:

I have also created a topic about it on the Mattermost forum, it can be found here:

5 лайков

Hello! I am getting a broken image link to the right of the mattermost post. I tried to see the image url and it looks like an actual post instead of an image:

http://destek.hugin.com.tr/t/hugin-destek-topluluguna-hos-geldiniz/183/1

Is it intended to be the post author image I wonder?

Any tips on how to fix it?

Hi @nommaz - sorry about that. It was indeed trying to load an image from the URL of the post, which clearly isn’t going to work :wink:

I’ve fixed it now, so if you update to the latest version of the plugin it should work as intended :slight_smile:

2 лайка

Hi David didnt work unfortunately

Are you sure it is not an issue with mattermost_provider.rb:68 ?

Thanks

Vedat

Oops, I made the change in the slack provider instead of mattermost :facepalm:

Just added another commit to correct the error, so please can you give it another try :slight_smile:

1 лайк

Thanks! All set now :slight_smile:

What’s up if I get a 422 error when trying (test) to hook to Mattermost?

Make sure you copied the webhook URL correctly, and that there are no spaces before/after the URL. Is your mattermost server accessible to the internet? Or just an internal network?

3 лайка

What’s the best way to handle multiple teams / multiple mattermost servers?

У меня включена интеграция чата с Mattermost — я подписался на все категории «верхнего уровня», которые отображаются через команду “/discourse watch”, но сообщения из «подкатегорий» не отслеживаются.

Вот пример поста: https://openziti.discourse.group/t/this-is-a-test-topic-in-the-sdks-category/271

Он корректно пересылается в Slack, но не пересылается в Mattermost. Slack может подписываться на «все категории», а Mattermost, похоже, не может.

Я перепробовал все возможные варианты синтаксиса, но безрезультатно. Есть какие-нибудь советы??

Заранее спасибо…

1 лайк

@david — извините за упоминание, но я не вижу посты Discourse в своей интеграции чата. Есть ли шанс, что вы всё ещё следите за этой темой?

На данный момент подкатегории автоматически не включаются при «подписке» на категорию. Вам нужно либо добавить каждую подкатегорию отдельно, либо использовать опцию «все категории».

1 лайк

Привет, спасибо за ответ!!! Было бы здорово, если бы я мог разобраться, «как». Похоже, плагин распознаёт только самые верхние категории?

Я нашёл/попробовал опцию «все категории», но, кажется, она тоже не работает? Ох, я бы очень хотел просто использовать «все», это было бы ИДЕАЛЬНО… Я что-то делаю не так? См. скриншот ниже

Привет, @david… Проблема в том, что я не могу понять, как подписаться на «подкатегорию», и, похоже, нет возможности выбрать «все»? Мне бы очень хотелось разобраться в этом.

Спасибо!

1 лайк

Извините за задержку с ответом, @Clint_Dovholuk!

Используя команды со слэшем, я думаю, что вы можете следить за всеми категориями так:

/discourse watch

Но самый простой способ настроить правила уведомлений — через панель администратора Discourse. Там все варианты четко отображены в интерфейсе, поэтому не нужно пытаться разобраться в точном синтаксисе «команд со слэшем». Для получения дополнительной информации ознакомьтесь с разделом «настройка правил» документации плагина.

2 лайка

Спасибо, @david.

Я уже публиковал скриншот команды со слэшем ранее. Повторно размещаю его здесь… Вы можете увидеть, что «подкатегории» не перечислены в одном или двух сообщениях выше…

Ранее я пробовал использовать страницу администратора, но выпадающий список сразу закрывался при её использовании… Однако нажатие стрелки вниз, похоже, освобождало то, что мне было нужно.

Мне ОЧЕНЬ нужна опция «Все». Это плагин, который я могу как-то отредактировать или исправить??? Сейчас это выглядит так :confused:

Чтобы получать уведомления обо всех темах, я рекомендую удалить все правила, привязанные к конкретным категориям, а затем добавить одно правило «все категории».

Можете ли вы предоставить больше деталей о том, что именно вы видите? Скриншоты или видео были бы очень кстати!

При редактировании «правила» вы должны иметь возможность использовать выпадающее меню категорий, чтобы выбрать «(нет категории)».

После сохранения это должно выглядеть так:

(«нет категории» в выпадающем меню — это явно неудачное описание того, что оно на самом деле означает. Я исправлю это).

Я думаю, что подкатегории опущены в тексте справки для экономии места. Но вы всё равно можете подписываться на категории, используя их «слэг» (название подкатегории из URL). Так, в случае с #howto:admins здесь, на Meta, это будет /discourse watch admins.