# 在 Slack 的私有频道中添加集成

**URL:** <https://meta.discourse.org/t/add-integration-to-private-channels-on-slack/155057>\
**Category:** Feature\
**Tags:** chat-integration\
**Created:** [2020年六月16日 21:04 UTC](https://meta.discourse.org/t/add-integration-to-private-channels-on-slack/155057 "2020-06-16T21:04:17Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![awlogan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/awlogan/32/62208_2.png) [@awlogan](https://meta.discourse.org/u/awlogan)\
**Post date:** [2020年六月16日 21:04 UTC](https://meta.discourse.org/t/add-integration-to-private-channels-on-slack/155057/1 "2020-06-16T21:04:17Z")

</div>

我正试图弄清楚如何让聊天集成能够发布到私有的 Slack 频道。我们已在使用任务管理器 Asana 实现了这一功能，但 Discourse 似乎不允许我这样做。

当我创建一个私有频道并进入“添加应用”页面时，Asana 为我提供了添加选项，但在 Discourse 中，我只看到查看选项。

我不确定这是否只是需要在 Slack 中为 Discourse 应用授予的权限问题。不幸的是，我不再管理我们的 Slack 实例，因此需要与 IT 团队配合进行测试。如有任何建议，不胜感激。

以下是尝试添加这两个应用时的截图：

 ![Screen Shot 2020-06-16 at 2.02.21 PM](https://global.discourse-cdn.com/meta/original/3X/1/b/1b1d56db8f5b51f416aedf3a0ad397b8531db5cf.png)

 ![Screen Shot 2020-06-16 at 2.02.33 PM](https://global.discourse-cdn.com/meta/original/3X/4/5/458322314233edf401e8b4e3ddbb804db16962d6.png)

---

<div class="post-metadata">

**Author:** ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)\
**Post date:** [2020年六月19日 18:34 UTC](https://meta.discourse.org/t/add-integration-to-private-channels-on-slack/155057/3 "2020-06-19T18:34:48Z")

</div>

我已在自己的 Slack 账户上测试过。在该账户中，我可以通过点击频道的“添加应用”链接，将 Discourse 应用添加到私密频道。这适用于 Slack 管理员是成员的私密频道，也适用于 Slack 管理员不是成员的私密频道。

如果您仅被允许 Discourse 应用_查看_私密频道，问题可能与授予该应用的权限有关。在我的账户中，我使用了以下权限，来自 [Set up Slack notifications using the discourse-chat-integration plugin](https://meta.discourse.org/t/set-up-slack-notifications-using-the-discourse-chat-integration-plugin/66730) 的第 5 步：

- `chat:write`
- `chat:write.customize`
- `users:read`
- `channels:history`
- `groups:history`
- `im:history`

---

<div class="post-metadata">

**Author:** ![awlogan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/awlogan/32/62208_2.png) [@awlogan](https://meta.discourse.org/u/awlogan)\
**Post date:** [2020年六月19日 22:46 UTC](https://meta.discourse.org/t/add-integration-to-private-channels-on-slack/155057/4 "2020-06-19T22:46:11Z")

</div>

没错，我们确实缺少两项权限（顶部聊天），但奇怪的是，即使已将应用在所有频道中可用，似乎只有当我邀请 Slack 管理员加入频道时，它才会在私有频道中开始工作。我猜是我们的相关权限设置有问题，不过下周我会和他一起进行更多测试。感谢更新。

---

<div class="post-metadata">

**Author:** ![awlogan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/awlogan/32/62208_2.png) [@awlogan](https://meta.discourse.org/u/awlogan)\
**Post date:** [2020年六月20日 01:53 UTC](https://meta.discourse.org/t/add-integration-to-private-channels-on-slack/155057/5 "2020-06-20T01:53:07Z")

</div>

好的，作为后续跟进，以下是我目前的测试进展。

我相信所有权限都已正确设置，但我的 Slack 管理员今天已经下班了。我注意到，当我尝试向一个私有的 Slack 频道发布消息时，系统报错称该频道不存在。我最初以为这可能是因为我刚创建了一个测试频道，于是我尝试使用一个较旧的测试频道，但在规则集中仍然收到了相同的错误提示。

当我点击该错误时，详细信息如下：

 ![Screen Shot 2020-06-19 at 6.36.33 PM](https://global.discourse-cdn.com/meta/original/3X/1/1/11c05b1a5d9cc979e228ac02a6d690ffedbec0df.png)

```
{
  "error_key": "chat_integration.provider.slack.errors.channel_not_found",
  "request": "",
  "response_code": "200",
  "response_body": "{\"ok\":false,\"error\":\"channel_not_found\"}"
}

```

随后，我将我的 Slack 管理员添加到该频道并再次尝试发布。这次操作顺利通过了。在他重新上线之前，我无法测试移除管理员后集成是否仍能正常工作。如果确实可以，那么这似乎是一个可行的变通方案，除非有一种方法可以在不添加 Slack 管理员的情况下，在私有频道上启动集成。

---

<div class="post-metadata">

**Author:** ![sunjam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sunjam/32/175682_2.png) [@sunjam](https://meta.discourse.org/u/sunjam)\
**Post date:** [2020年六月20日 01:58 UTC](https://meta.discourse.org/t/add-integration-to-private-channels-on-slack/155057/6 "2020-06-20T01:58:16Z")

</div>

@awlogan 我通过邀请聊天机器人到 Slack 中的每个特定频道解决了这个完全相同的错误，具体方法如下：

`/invite @discourse_integration_name_you_chose`

> [@Slack integration Not Working - Not in Channel Error](https://meta.discourse.org/t/slack-integration-not-working-not-in-channel-error/140920/2?u=sunjam):
>
> To solve this, you need to add your integration bot to the particular Slack channel. Go to the channel in Slack and type in the following command: /invite @discourse\_integration NOTE: if you’ve named your integration something else, you’ll need to use that handle.

---

<div class="post-metadata">

**Author:** ![awlogan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/awlogan/32/62208_2.png) [@awlogan](https://meta.discourse.org/u/awlogan)\
**Post date:** [2020年六月20日 02:04 UTC](https://meta.discourse.org/t/add-integration-to-private-channels-on-slack/155057/7 "2020-06-20T02:04:25Z")

</div>

感谢 @sunjam，我得查一下那个机器人是如何在 Slack 中设置的。那些显而易见的名称（它发布时使用的名称，如 discourse\_integration）似乎无法通过斜杠邀请命令找到。不过还是感谢你的提示！

---

<div class="post-metadata">

**Author:** ![sunjam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sunjam/32/175682_2.png) [@sunjam](https://meta.discourse.org/u/sunjam)\
**Post date:** [2020年六月20日 14:56 UTC](https://meta.discourse.org/t/add-integration-to-private-channels-on-slack/155057/8 "2020-06-20T14:56:35Z")

</div>

在 Slack 的文档化设置流程中创建机器人用户后，您必须将其邀请到每个特定的房间。\<\< 如果有更简便的方法，我很希望能知道。

---

<div class="post-metadata">

**Author:** ![Eric\_Woelker](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/eric_woelker/32/287638_2.png) [@Eric\_Woelker](https://meta.discourse.org/u/Eric_Woelker)\
**Post date:** [2023年二月3日 21:25 UTC](https://meta.discourse.org/t/add-integration-to-private-channels-on-slack/155057/9 "2023-02-03T21:25:05Z")

</div>

您好！自从这个帖子上次更新以来，有人成功地将 Discourse 集成到 Slack 的私有频道了吗？我尝试了几种方法，但一直无法使其正常工作并将帖子从 Discourse 拉取到私有频道，就像它们可以被拉取到公共频道一样。有人成功了吗？您有什么建议可以分享吗？谢谢！
