Discourse 聊天集成

:information_source: Chat Integration is for using an external chat system together with Discourse — you may be looking for Discourse Chat which adds Chat functionality directly to Discourse.

:discourse2: Summary Discourse Chat Integration allows you to integrate your chat system of choice with Discourse.
:open_book: Install Guide This plugin is bundled with Discourse core. There is no need to install the plugin separately.

Features

discourse-chat-integration allows sending notifications about new Discourse posts to ‘group chats’ on a number of instant messaging platforms.

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:

Configuration

  1. In your site settings, check chat_integration_enabled is :heavy_check_mark:
  2. Click on one of the providers below to see provider-specific setup instructions
  3. For more details, read ‘Configuring Rules’ below
Provider Notifications Slash Commands Post Transcripts Threaded Replies
Slack :white_check_mark: :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:
Google Chat :white_check_mark:
Matrix (element.io) :white_check_mark:
Zulip :white_check_mark:
Rocket.Chat :white_check_mark:
Gitter :white_check_mark:
Flowdock :white_check_mark:
Stride Docs
Microsoft Teams :white_check_mark:
Basecamp Docs
IRC Cloud Docs
Flock Docs
Webex :white_check_mark:

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 with threaded replies - notify for new posts matching this rule, create per-topic threads on the chat provider (not available in all integrations)
    • All posts and replies - notify for new posts matching this rule
    • First post only - notify only for new topics matching this rule
    • Tag added to topic - notify when a tag is added to a topic (the create post for category and tag changes site setting must be enabled for this to work)
    • 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. (Note that at this time, only the Slack integration implements threads.)

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.

To load a transcript for a Slack thread, you can use /discourse post thread {url}, where {url} is the permalink of the first message in the thread. For example:

/discourse post thread https://<slackname>.slack.com/archives/C6029G78F/p1522952993000017

Alternatively, you can use /discourse post with a thread-specific permalink like this:

/discourse post https://foo.slack.com/archives/G49KKS6AX/p1523062012000911?thread_ts=1523091738.000088&cid=G49KKS6AC

In both cases the “first/last message” UI is skipped - the entire thread is included in the transcript.

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.

CHANGELOG

TODO

Last edited by @tobiaseigen 2025-07-16T21:09:49Z

Check documentPerform check on document:
115 个赞

添加对 Discourse 自己的 ActivityPub Plugin 的支持会很有趣,这样就可以根据聊天集成中的标签和其他过滤器来触发发布。

1 个赞

您好,去年 Telegram 宣布了论坛/主题(群聊内的迷你聊天)。我尝试将每个单独的迷你聊天连接到我网站的一个或另一个类别。但据我所知,主题地址不受插件支持?例如,在我的例子中,每个主题都有一个地址,如下所示:@telegram_topic /1@telegram_topic /2@telegram_topic /3……
如果我在行中插入标准的聊天名称,例如 @telegram_chat,它就可以正常工作。
如果插件能够插入类似的聊天地址(../1),那将非常方便,这样用户就不必订阅许多与网站特定类别关联的独立频道。

1 个赞

您是否考虑过使用标签来实现这一点?

:thinking: 我认为使用标签并不完全适合我的情况。因为即使有标签的帮助,我也不希望所有的通知都进入一个频道,造成信息噪音。同时,我宁愿有一个群聊,而不是为 20 个类别/标签创建 20 个频道,在群聊中我可以组织几个迷你主题聊天(按类别/标签),每个用户都可以查看他们需要的迷你聊天,并且能够查看其他迷你聊天。我感到很困扰,因为在我的地区(亚洲),大多数人使用 WhatsApp 和 Telegram 聊天——论坛并不受欢迎。但我正在努力寻找一个折衷方案)。

附注。如果我经常重复自己,请不要评判我,我只是在努力正确地表达我的想法,因为我使用谷歌翻译。

1 个赞

据我理解,您应该能够过滤哪些标签适用于哪些聊天。

在我看来,我们说的是不同的事情 :thinking: 我没有关于按标签/类别过滤聊天的问题。
背景。以前,Telegram 有频道和聊天(不包括机器人)。这些频道/聊天室有一个用户名,大约是 @chat_username@channel_username
从去年开始,Telegram 有机会将聊天变成论坛,其中包含类似这样的迷你主题聊天。这些迷你聊天有自己的用户名,例如 @chat_username /1@chat_username /2。这种带有迷你聊天的聊天的好处是,用户不再需要订阅几个独立的聊天,而只需订阅一个聊天(例如,以我的网站名称命名),就可以访问许多用户感兴趣的迷你聊天(在我的例子中,每个迷你聊天将针对网站上的特定类别)。
现在我想将这些迷你聊天连接到这个插件,但我觉得插件不支持迷你聊天用户名,如 chat_username /1

1 个赞

有没有办法创建一个规则,我可以标记一条新消息和/或回复,使其不会发布到目标聊天系统(在本例中为 Slack)?

嘿 Albert,如果我们讨论的是普通的 Discourse 标签,你可以设置一个 ‘静音’ 过滤器 来阻止带有该标签的主题在 Slack 中触发通知。

但就单个帖子而言,没有办法过滤掉它们。

1 个赞

我好像和你一样,Aizada:

我希望能有一个 Telegram 群聊,并启用“话题”(大致对应 Discourse 上的分类),然后在 Discourse/聊天集成设置中指定它应该发布到哪个话题。

我现在尝试创建一个带话题的群聊(只有我和机器人),但在话题中输入 /help 时,机器人却在普通聊天中回复。

@david,你研究过这个问题吗? 我找到了这个 Stack Overflow 帖子,它展示了如何获取 message_thread_id(即话题 ID),并提到机器人 API 在 6.3 版本中已支持此功能。

无论如何,感谢你的工作!:heart_hands:t2:

1 个赞

您好 @ErlendMS :wave:。我们目前没有此插件的增强功能路线图,但如果有人想为 Telegram 集成添加“线程”(又名主题)支持,那很可能是 #pr-welcome。

我们确实在 Slack 集成中提供了一些线程支持,因此应该可以重用其中一些逻辑。

3 个赞

是否可以使用此插件在帖子被标记为待审核时在 Slack 中收到通知?谢谢。

此插件是否公开了其他 API 函数?

我应该在哪里请求 PR 审查?我上周晚些时候提交了这个 PR 来添加一个新提供商,但它仍然在等待审查者。我查阅了 Meta 上的各种开发者指南,但找不到关于正确 PR 请求的指南。

这是我的 PR:FEATURE: Added Power Automate as a new provider by benoitdesnoyers · Pull Request #204 · discourse/discourse-chat-integration · GitHub

谢谢,

1 个赞

大家好!我们刚刚合并了此 pr 用于聊天集成插件

此更改旨在从聊天集成中的规则过滤中删除 tags_changed 选项——我们之所以进行此更改,是因为我们正在 移除 当主题的类别或标签更改时创建小型操作帖子 设置。

但是,如果您安装了 discourse automation,功能将保持_相同_。下次运行此插件的迁移时,它将向 discourse automation 插件 添加一个脚本,该脚本的运行方式将与我们目前拥有的类似。

这是将创建的自动化示例:

它将根据我拥有的类别和关注的标签发送到我的频道。

${ADDED_AND_REMOVED} 是默认文本;它的行为将与规则相同。

我们还为此脚本选项添加了一些可以在消息中使用的选项:

  • ${TOPIC} 用于主题名称
  • ${REMOVED_TAGS} 用于移除的标签
  • ${ADDED_TAGS} 用于添加的标签
    当有标签时,移除和添加才会触发。
    例如:added: ${ADDED_TAGS} 消息仅在有添加的标签时才会触发
4 个赞

我们遇到了另一个 PR 的问题(使用其他提供商的用户在主题标签更改时无法使用自动化),为了解决这个问题,我们创建了这个新的 PR,其中我们考虑了_所有_提供商。

“创建当主题的类别或标签更改时的小型操作帖子”设置将不会出现在聊天集成中。

如果您安装了 discourse automation,下次运行此插件的迁移时,它将向 discourse automation 插件添加一个脚本,该脚本的运行方式与我们目前的方式类似。


您的自动化将如下所示:

您的提供商是已启用的提供商。

例如,我启用了 DiscordSlackTelegramGoogle Chat

您的频道名称是您在聊天集成设置中给它起的名称。

例如,这里的名称是Spidey

3 个赞

我们为 Automation/chat-integration 带来了一批新更改

在此批新更改中,值得注意的包括:

  • 我们添加了 Trigger with PMs(私信触发),让您可以控制此自动化是否在收到私信时触发。
  • 解决了 Topic tags changed(主题标签更改)自动化在创建主题时被触发的问题。
3 个赞

如前所述 – 此处

为分类和标签更改创建帖子站点设置目前可能会泄露私有标签/分类;我们发现的一种保留该功能的方法是将其移至“耳语”(whispers):

它的工作方式与小型帖子类似,但现在,您需要拥有 whisper allowed groups(允许耳语的组)以及 某个 组才能使其正常工作。

我已将一个 PR 合并到核心(core)中进行了此项更改,并为 chat-integration 合并了一个 PR,移除了该设置的使用;添加回来的自动化功能应与小型操作(small action)一对一,如果您有任何问题,请告知我们!

3 个赞

我为这个插件带来了一些更新 :steam_locomotive:

我们为“发送聊天集成消息”自动化添加了 触发条件 字段。

它有什么作用?

它会检查标签何时:

  • 添加和移除(默认)
  • 添加
  • 移除

目前,此检查是包含性的。

一个很好的例子是,如果我将其设置为 添加;为了让此自动化运行,必须向主题添加_任何_标签。

当设置为“添加标签”时,自动化表如下所示:

向主题添加标签 从主题移除标签 自动化是否运行?
:white_check_mark: :cross_mark: :white_check_mark:
:white_check_mark: :white_check_mark: :white_check_mark:
:cross_mark: :white_check_mark: :cross_mark:

当设置为“移除标签”时,自动化表如下所示:

从主题移除标签 向主题添加标签 自动化是否运行?
:white_check_mark: :cross_mark: :white_check_mark:
:white_check_mark: :white_check_mark: :white_check_mark:
:cross_mark: :white_check_mark: :cross_mark:
2 个赞


主题:无法访问“插件”部分以进行聊天集成设置

您好,

我是 LXDAO 论坛的管理员,我正在尝试设置 Discourse Chat Integration 插件以连接到 Telegram。根据官方文档,我应该可以在管理面板的“插件”部分进行配置。

但是,在我的管理员仪表板中,我只能访问四个部分:常规、审核、安全和报告。“文档中提到的插件”部分似乎不可用。

您能否帮助我理解:

  1. 聊天集成插件是否已安装在我们的论坛上?
  2. 我是否需要额外的权限才能访问“插件”部分?
  3. 如果我们使用的是托管的 Discourse 解决方案,在插件安装/配置方面是否存在任何限制?

作为管理员,我应该采取哪些步骤才能为我们的社区正确设置 Telegram 集成?

感谢您的帮助!