Chatroom Integration Plugin (discourse-chat-integration)

Continuing from Common event system for chatrooms

:speech_balloon: discourse-chat-integration :speech_balloon:

discourse-chat-integration is the product of my Google Summer of Code project with Discourse. It allows sending notifications about new Discourse posts to ‘group chats’ on a number of instant messaging platforms.

It is based on, and aims to supersede, the existing discourse-slack-official plugin.

Notifications can be triggered by new topics, new replies, messages to a group, or mentions of a group. A notification in your instant messaging system will look something like this:

16

Getting Started

  1. Install the plugin by following the Install Plugin instructions. The plugin’s repository address is
    https://github.com/discourse/discourse-chat-integration.git
    
  2. In your site settings, check chat_integration_enabled is :heavy_check_mark:
  3. Click on one of the providers below to see provider-specific setup instructions
  4. For more details, read ‘Configuring Rules’ below
Provider Notifications Slash Commands Post Transcripts
Slack :white_check_mark: :white_check_mark: :white_check_mark:
Telegram :white_check_mark: :white_check_mark:
Discord :white_check_mark:
Mattermost :white_check_mark: :white_check_mark:
Matrix (riot.im) :white_check_mark:
Zulip :white_check_mark:
Rocket.Chat :white_check_mark:
Gitter :white_check_mark:
Flowdock :white_check_mark:
Stride Docs
Microsoft Teams Docs
Basecamp Docs
IRC Cloud Docs
Flock Docs

Terminology

There are three key concepts in discourse-chat-integration: Providers, Channels and Rules

Configuring Rules

In your forum’s admin panel, under Plugins, you should see a Chat Integrations section. Within that there will be tabs for each of your enabled providers:

Rules have a number of options which can be configured:

  • Type:
    • Normal - send notifications based on standard posts on the forum
    • Group Message - send notifications based on private messages which a specified group is a part of
    • Group Mention - send notifications whenever specified group is @mentioned in a standard post on the forum (mentions in private messages are ignored)
  • Filter:
    • All posts and replies - notify for new posts matching this rule
    • First post only - notify only for new topics matching this rule
    • Mute - prevent notifications matching this rule
  • Category (if type is ‘Normal’)
    • Match posts based on their category. Leave as “(all categories)” to match all posts on the forum
  • Group (if type is ‘Group Message’ or ‘Group Mention’)
    • Specify the group you want to receive notifications for
  • Tags
    • Enter a list of tags to match posts with at least one of the listed tags. Leave blank to match all posts

Multiple rules

When multiple rules match a post, the top-most rule in the user interface is executed. Rules are first sorted according to the criteria:

  1. Group mentions
  2. Group messages
  3. Normal

and then sorted within that by

  1. Mute
  2. All posts and replies
  3. First post only

For example, with the following rules

Filter Category Tags
All posts and replies Mentions of: @team (all tags)
Mute #support (all tags)
First post only #support #unsupported-install
All posts and replies (all categories) (all tags)

Notifications would be triggered for

but not for

Security/Permissions

The site setting “chat integration discourse username” allows you to secure your notifications against leaking private information.

By default the system account is used, which means that there is no restriction on notifications sent. To secure your notifications you should create a non-staff user with appropriate access privileges, and enter its username in the site setting.

Slash Commands

If your provider supports slash commands, you can manage rules from within your chat interface. Each provider varies slightly in syntax, but in general they follow a similar structure.

The commands available are

Posting a transcript

If your provider supports transcript posting, you can post your instant messaging history to discourse. This is currently only supported for the Slack provider. Note: You will need to be using the “Access Token” method of connecting to Slack.

Send /discourse post to see the interface. The plugin will try and “guess” where your current conversation starts, by looking for a gap in the message history of more than 3 minutes.

Alternatively, you can specify a number of posts after the command, or a URL to the first message.

Adding new providers

Option 1: Submit a PR implementing your provider:

Option 2: Use your own plugin:
It is possible for third party plugins to register new “providers”. As an example, I’ve created a provider which sends webhooks to IFTTT. This could be used to automatically publish all posts in a category to facebook… or turn on your light when someone posts in #feature… or feed your fish whenever there’s a new #plugin.

58 Likes
Set up Slack notifications using the discourse-chat-integration plugin
Set up Mattermost notifications using the discourse-chat-integration plugin
Set up Rocket Chat notifications using the discourse-chat-integration plugin
Set up Matrix (riot.im) notifications using the discourse-chat-integration plugin
Set up HipChat notifications using the discourse-chat-integration plugin
Set up Gitter notifications using the discourse-chat-integration plugin
Set up Zulip notifications using the discourse-chat-integration plugin
Set up CA Flowdock notifications using the discourse-chat-integration plugin
Telegram Notifications Plugin (discourse-telegram-notifications)
Telegram Notifications Plugin (discourse-telegram-notifications)
Will Rocket Chat and others get transcript posting?
Configuring Slack for Discourse Slack Plugin
iOS Mobile App Notifications
Chat client suggestions?
Discourse-official-slack: no error message after failed post to slack
[Deprecated] The Official Discourse Slack Plugin
Set up Slack notifications using the discourse-chat-integration plugin
Dynamic of community with a chat and discourse page
Steam Authentication & Integration
Gitter support in chat-integration appears to be missing settings and rules
Contributor Interviews – David Taylor
Writing messages from Slack to Discourse
Recommended chat platform for Discourse
Notifications integration for Facebook and Twitter
Send summary of new posts to chat instead of every post update
Auto Post New Topics to Social Media
HipChat Integration
Does Discourse have a chat room function?
About the chat-integration category
[Deprecated] The Official Discourse Slack Plugin
Can you enable a plugin that integrates slack and discourse?
Advice for getting my little game dev community "out there?"
Set up Slack notifications using the discourse-chat-integration plugin
Can Discourse Integrate with Free Slack?
Checking if post or thread - Ruby
Adding a new provider to discourse-chat-integration
Discourse & Drift Chatbot
Internal Onebox links cause full page reload
Writing messages from Slack to Discourse
Help configuring Slack Discourse plugin
Plugin for auto posting to social media?
Chat-integration
Telegram Notifications Plugin (discourse-telegram-notifications)
Tool for Tossing out Notifications via Discord
Chat Integration leaks Babble chats

Please post replies to the #plugin:chat-integration category.

2 Likes

Similar to the following post:

I also have been bitten by handling the plugin the categories not in a recursive manner: having just 2 private categories and muting the main secret ones, I got notifications from subcategories.
So if I have the following category tree:

secret-category1
├── sub11
└── sub12
secret-category2
├── sub21
└── sub22
public-category
...

and muting secret-category1 and secret-category2, I still got notifications from the four subs :frowning:

Suggestion, disable display full name on discord message if the forum have “enable names” disabled. I imported users from other forum CMS and has this display name wrong, the plugin needs to check this option, I think.

Example now:
UserName @user
Message

Names disabled:
@user
Message

Should I hope there will be a switch in the options to create a rule including all subcategories?

Following the instructions, you come to

## Configuring Rules

In your forum’s admin panel, under <kbd>Plugins</kbd>, you should see a <kbd>Chat Integrations</kbd> section. Within that there will be tabs for each of your enabled providers
...

However, in my forum’s admin panel I can see the Plugins section, but there is no Chat Integrations section. The plugins button just displays the list of plugins and their status with a link to the settings:

discourse-chat-integration	0.1	Y	 Settings

Under the settings, I can add OAuth tokens/webhook URLs but I cannot configure specific applications. Have these settings moved?

Hope this will be enough to help you find it.

Just an FYI, tried to install the plugin and got this error.

bash-4.2# RAILS_ENV=production bundle exec rake assets:precompile --trace
** Invoke assets:precompile (first_time)
** Invoke assets:environment (first_time)
** Execute assets:environment
** Invoke environment (first_time)
** Execute environment
rake aborted!
NameError: undefined local variable or method `site_setting_saved' for main:Object
/bitnami/discourse/plugins/discourse-chat-integration/lib/discourse_chat/provider/telegram/telegram_initializer.rb:19:in `<top (required)>'
/bitnami/discourse/plugins/discourse-chat-integration/lib/discourse_chat/provider/telegram/telegram_provider.rb:111:in `require_relative'
/bitnami/discourse/plugins/discourse-chat-integration/lib/discourse_chat/provider/telegram/telegram_provider.rb:111:in `<top (required)>'
/bitnami/discourse/plugins/discourse-chat-integration/lib/discourse_chat/provider.rb:95:in `require_relative'
/bitnami/discourse/plugins/discourse-chat-integration/lib/discourse_chat/provider.rb:95:in `<top (required)>'
/opt/bitnami/discourse/plugins/discourse-chat-integration/app/initializers/discourse_chat.rb:52:in `require_relative'
/opt/bitnami/discourse/plugins/discourse-chat-integration/app/initializers/discourse_chat.rb:52:in `<top (required)>'
/opt/bitnami/discourse/plugins/discourse-chat-integration/plugin.rb:19:in `require_relative'
/opt/bitnami/discourse/plugins/discourse-chat-integration/plugin.rb:19:in `block in activate!'
/opt/bitnami/discourse/lib/plugin/instance.rb:320:in `block in notify_after_initialize'
/opt/bitnami/discourse/lib/plugin/instance.rb:318:in `each'
/opt/bitnami/discourse/lib/plugin/instance.rb:318:in `notify_after_initialize'
/opt/bitnami/discourse/config/application.rb:275:in `each'
/opt/bitnami/discourse/config/application.rb:275:in `block in <class:Application>'
/opt/bitnami/discourse/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.2.1/lib/active_support/lazy_load_hooks.rb:69:in `block in execute_hook'
/opt/bitnami/discourse/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.2.1/lib/active_support/lazy_load_hooks.rb:62:in `with_execution_control'
/opt/bitnami/discourse/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.2.1/lib/active_support/lazy_load_hooks.rb:67:in `execute_hook'
/opt/bitnami/discourse/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.2.1/lib/active_support/lazy_load_hooks.rb:52:in `block in run_load_hooks'
/opt/bitnami/discourse/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.2.1/lib/active_support/lazy_load_hooks.rb:51:in `each'
/opt/bitnami/discourse/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.2.1/lib/active_support/lazy_load_hooks.rb:51:in `run_load_hooks'
/opt/bitnami/discourse/vendor/bundle/ruby/2.5.0/gems/railties-5.2.2.1/lib/rails/application/finisher.rb:75:in `block in <module:Finisher>'
/opt/bitnami/discourse/vendor/bundle/ruby/2.5.0/gems/railties-5.2.2.1/lib/rails/initializable.rb:32:in `instance_exec'
/opt/bitnami/discourse/vendor/bundle/ruby/2.5.0/gems/railties-5.2.2.1/lib/rails/initializable.rb:32:in `run'
/opt/bitnami/discourse/vendor/bundle/ruby/2.5.0/gems/railties-5.2.2.1/lib/rails/initializable.rb:61:in `block in run_initializers'
/opt/bitnami/ruby/lib/ruby/2.5.0/tsort.rb:228:in `block in tsort_each'
/opt/bitnami/ruby/lib/ruby/2.5.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
/opt/bitnami/ruby/lib/ruby/2.5.0/tsort.rb:431:in `each_strongly_connected_component_from'
/opt/bitnami/ruby/lib/ruby/2.5.0/tsort.rb:349:in `block in each_strongly_connected_component'
/opt/bitnami/ruby/lib/ruby/2.5.0/tsort.rb:347:in `each'
/opt/bitnami/ruby/lib/ruby/2.5.0/tsort.rb:347:in `call'
/opt/bitnami/ruby/lib/ruby/2.5.0/tsort.rb:347:in `each_strongly_connected_component'
/opt/bitnami/ruby/lib/ruby/2.5.0/tsort.rb:226:in `tsort_each'
/opt/bitnami/ruby/lib/ruby/2.5.0/tsort.rb:205:in `tsort_each'
/opt/bitnami/discourse/vendor/bundle/ruby/2.5.0/gems/railties-5.2.2.1/lib/rails/initializable.rb:60:in `run_initializers'
/opt/bitnami/discourse/vendor/bundle/ruby/2.5.0/gems/railties-5.2.2.1/lib/rails/application.rb:361:in `initialize!'
/opt/bitnami/discourse/vendor/bundle/ruby/2.5.0/gems/railties-5.2.2.1/lib/rails/railtie.rb:190:in `public_send'
/opt/bitnami/discourse/vendor/bundle/ruby/2.5.0/gems/railties-5.2.2.1/lib/rails/railtie.rb:190:in `method_missing'
/opt/bitnami/discourse/config/environment.rb:5:in `<top (required)>'
/opt/bitnami/discourse/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.2.1/lib/active_support/dependencies.rb:291:in `require'
/opt/bitnami/discourse/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.2.1/lib/active_support/dependencies.rb:291:in `block in require'
/opt/bitnami/discourse/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.2.1/lib/active_support/dependencies.rb:257:in `load_dependency'
/opt/bitnami/discourse/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.2.1/lib/active_support/dependencies.rb:291:in `require'
/opt/bitnami/discourse/vendor/bundle/ruby/2.5.0/gems/railties-5.2.2.1/lib/rails/application.rb:337:in `require_environment!'
/opt/bitnami/discourse/vendor/bundle/ruby/2.5.0/gems/railties-5.2.2.1/lib/rails/application.rb:520:in `block in run_tasks_blocks'
/opt/bitnami/discourse/vendor/bundle/ruby/2.5.0/gems/rake-12.3.2/lib/rake/task.rb:273:in `block in execute'
/opt/bitnami/discourse/vendor/bundle/ruby/2.5.0/gems/rake-12.3.2/lib/rake/task.rb:273:in `each'
/opt/bitnami/discourse/vendor/bundle/ruby/2.5.0/gems/rake-12.3.2/lib/rake/task.rb:273:in `execute'
/opt/bitnami/discourse/vendor/bundle/ruby/2.5.0/gems/rake-12.3.2/lib/rake/task.rb:214:in `block in invoke_with_call_chain'
/opt/bitnami/ruby/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
/opt/bitnami/discourse/vendor/bundle/ruby/2.5.0/gems/rake-12.3.2/lib/rake/task.rb:194:in `invoke_with_call_chain'
/opt/bitnami/discourse/vendor/bundle/ruby/2.5.0/gems/rake-12.3.2/lib/rake/task.rb:183:in `invoke'
/opt/bitnami/discourse/vendor/bundle/ruby/2.5.0/gems/sprockets-rails-3.2.1/lib/sprockets/rails/task.rb:62:in `block (2 levels) in define'
/opt/bitnami/discourse/vendor/bundle/ruby/2.5.0/gems/rake-12.3.2/lib/rake/task.rb:273:in `block in execute'
/opt/bitnami/discourse/vendor/bundle/ruby/2.5.0/gems/rake-12.3.2/lib/rake/task.rb:273:in `each'
/opt/bitnami/discourse/vendor/bundle/ruby/2.5.0/gems/rake-12.3.2/lib/rake/task.rb:273:in `execute'
/opt/bitnami/discourse/vendor/bundle/ruby/2.5.0/gems/rake-12.3.2/lib/rake/task.rb:214:in `block in invoke_with_call_chain'
/opt/bitnami/ruby/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
/opt/bitnami/discourse/vendor/bundle/ruby/2.5.0/gems/rake-12.3.2/lib/rake/task.rb:194:in `invoke_with_call_chain'
/opt/bitnami/discourse/vendor/bundle/ruby/2.5.0/gems/rake-12.3.2/lib/rake/task.rb:238:in `block in invoke_prerequisites'
/opt/bitnami/discourse/vendor/bundle/ruby/2.5.0/gems/rake-12.3.2/lib/rake/task.rb:236:in `each'
/opt/bitnami/discourse/vendor/bundle/ruby/2.5.0/gems/rake-12.3.2/lib/rake/task.rb:236:in `invoke_prerequisites'
/opt/bitnami/discourse/vendor/bundle/ruby/2.5.0/gems/rake-12.3.2/lib/rake/task.rb:213:in `block in invoke_with_call_chain'
/opt/bitnami/ruby/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
/opt/bitnami/discourse/vendor/bundle/ruby/2.5.0/gems/rake-12.3.2/lib/rake/task.rb:194:in `invoke_with_call_chain'
/opt/bitnami/discourse/vendor/bundle/ruby/2.5.0/gems/rake-12.3.2/lib/rake/task.rb:183:in `invoke'
/opt/bitnami/discourse/vendor/bundle/ruby/2.5.0/gems/rake-12.3.2/lib/rake/application.rb:160:in `invoke_task'
/opt/bitnami/discourse/vendor/bundle/ruby/2.5.0/gems/rake-12.3.2/lib/rake/application.rb:116:in `block (2 levels) in top_level'
/opt/bitnami/discourse/vendor/bundle/ruby/2.5.0/gems/rake-12.3.2/lib/rake/application.rb:116:in `each'
/opt/bitnami/discourse/vendor/bundle/ruby/2.5.0/gems/rake-12.3.2/lib/rake/application.rb:116:in `block in top_level'
/opt/bitnami/discourse/vendor/bundle/ruby/2.5.0/gems/rake-12.3.2/lib/rake/application.rb:125:in `run_with_threads'
/opt/bitnami/discourse/vendor/bundle/ruby/2.5.0/gems/rake-12.3.2/lib/rake/application.rb:110:in `top_level'
/opt/bitnami/discourse/vendor/bundle/ruby/2.5.0/gems/rake-12.3.2/lib/rake/application.rb:83:in `block in run'
/opt/bitnami/discourse/vendor/bundle/ruby/2.5.0/gems/rake-12.3.2/lib/rake/application.rb:186:in `standard_exception_handling'
/opt/bitnami/discourse/vendor/bundle/ruby/2.5.0/gems/rake-12.3.2/lib/rake/application.rb:80:in `run'
/opt/bitnami/discourse/vendor/bundle/ruby/2.5.0/gems/rake-12.3.2/exe/rake:27:in `<top (required)>'
/opt/bitnami/discourse/vendor/bundle/ruby/2.5.0/bin/rake:23:in `load'
/opt/bitnami/discourse/vendor/bundle/ruby/2.5.0/bin/rake:23:in `<top (required)>'
/opt/bitnami/ruby/lib/ruby/site_ruby/2.5.0/bundler/cli/exec.rb:74:in `load'
/opt/bitnami/ruby/lib/ruby/site_ruby/2.5.0/bundler/cli/exec.rb:74:in `kernel_load'
/opt/bitnami/ruby/lib/ruby/site_ruby/2.5.0/bundler/cli/exec.rb:28:in `run'
/opt/bitnami/ruby/lib/ruby/site_ruby/2.5.0/bundler/cli.rb:463:in `exec'
/opt/bitnami/ruby/lib/ruby/site_ruby/2.5.0/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/opt/bitnami/ruby/lib/ruby/site_ruby/2.5.0/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
/opt/bitnami/ruby/lib/ruby/site_ruby/2.5.0/bundler/vendor/thor/lib/thor.rb:387:in `dispatch'
/opt/bitnami/ruby/lib/ruby/site_ruby/2.5.0/bundler/cli.rb:27:in `dispatch'
/opt/bitnami/ruby/lib/ruby/site_ruby/2.5.0/bundler/vendor/thor/lib/thor/base.rb:466:in `start'
/opt/bitnami/ruby/lib/ruby/site_ruby/2.5.0/bundler/cli.rb:18:in `start'
/opt/bitnami/ruby/lib/ruby/gems/2.5.0/gems/bundler-1.17.3/exe/bundle:30:in `block in <top (required)>'
/opt/bitnami/ruby/lib/ruby/site_ruby/2.5.0/bundler/friendly_errors.rb:124:in `with_friendly_errors'
/opt/bitnami/ruby/lib/ruby/gems/2.5.0/gems/bundler-1.17.3/exe/bundle:22:in `<top (required)>'
/opt/bitnami/ruby/bin/bundle:23:in `load'
/opt/bitnami/ruby/bin/bundle:23:in `<main>'
Tasks: TOP => environment
bash-4.2#