--- title: "How To Integrate Tulip with Slack" slug: "how-to-integrate-tulip-with-slack" updated: 2023-11-03T16:42:25Z published: 2023-11-03T16:42:25Z canonical: "support.tulip.co/how-to-integrate-tulip-with-slack" --- > ## Documentation Index > Fetch the complete documentation index at: https://support.tulip.co/llms.txt > Use this file to discover all available pages before exploring further. # 如何将 Tulip 与 Slack 整合 ## 如何将 Tulip 与 Slack 集成 *了解如何使用 HTTP 连接器从 Tulip 应用程序发送 Slack 消息。* 本文将向你展示如何使用 Tulip 的 HTTP 连接器向你公司 Slack 工作区中的频道发送消息。 如果你还不熟悉 Tulip HTTP 连接器,请先看看这篇文章:[HTTP 连接器概述](https://support.tulip.co/docs/an-overview-of-http-connectors) ## 设置 Slack 要让 Tulip 应用程序发布 Slack 消息,首先需要在 Slack 工作区中创建一个应用程序,"监听 "来自 Tulip 通过 webhook 发出的请求。 以下是步骤的简短摘要,但你可以查看下面的 Slack 文章,了解全部细节:[使用传入网络钩子发送消息](https://api.slack.com/messaging/webhooks) 以下步骤假定您已在浏览器中登录到 Slack 工作区。如果没有,系统将提示您登录: ![](https://cdn.document360.io/7c6ff534-cad3-4fc8-9583-912c4016362f/Images/Documentation/How%20To%20Integrate%20Tulip%20with%20Slack_200622704.png) 首先,[创建一个新的 Slack 应用程序](https://api.slack.com/apps?new_app=1): ![](https://cdn.document360.io/7c6ff534-cad3-4fc8-9583-912c4016362f/Images/Documentation/How%20To%20Integrate%20Tulip%20with%20Slack_200602933.png) 在新应用程序中,选择 "传入网络钩子": ![](https://cdn.document360.io/7c6ff534-cad3-4fc8-9583-912c4016362f/Images/Documentation/How%20To%20Integrate%20Tulip%20with%20Slack_200603338.png) 激活该应用程序的传入 Webhooks,点击 "Add New Webhook to Workspace(向工作区添加新的 Webhook)",然后选择您希望从郁金香发布消息的频道: ![](https://cdn.document360.io/7c6ff534-cad3-4fc8-9583-912c4016362f/Images/Documentation/How%20To%20Integrate%20Tulip%20with%20Slack_200604850.png) 分步图片: ![](https://cdn.document360.io/7c6ff534-cad3-4fc8-9583-912c4016362f/Images/Documentation/How%20To%20Integrate%20Tulip%20with%20Slack_200606746.png) ![How To Integrate Tulip with Slack](https://cdn.document360.io/7c6ff534-cad3-4fc8-9583-912c4016362f/Images/Documentation/How%20To%20Integrate%20Tulip%20with%20Slack_200606853.png) ![How To Integrate Tulip with Slack](https://cdn.document360.io/7c6ff534-cad3-4fc8-9583-912c4016362f/Images/Documentation/How%20To%20Integrate%20Tulip%20with%20Slack_200606942.png) ![How To Integrate Tulip with Slack](https://cdn.document360.io/7c6ff534-cad3-4fc8-9583-912c4016362f/Images/Documentation/How%20To%20Integrate%20Tulip%20with%20Slack_200607039.png) 您的 Slack 应用程序现在有了一个唯一的 Webhook URL,您可以用它将消息发布到指定的频道。请记住,虽然别人几乎不可能猜到这个 URL,但网络钩子是未经验证的,这意味着任何拥有该 URL 的人都可以向其发布信息。 如果你熟悉电脑的命令行界面(如 Windows 上的 cmd.exe 或 Mac 上的 Terminal),可以使用 Slack 应用程序中提供的 curl 请求示例来测试 webhook: ![](https://cdn.document360.io/7c6ff534-cad3-4fc8-9583-912c4016362f/Images/Documentation/How%20To%20Integrate%20Tulip%20with%20Slack_200620308.png) 也可以使用基于浏览器的免费 curl 实用程序,如[https://reqbin.com/curl](https://reqbin.com/curl)。 无论使用哪种方法,你都会看到 "Hello, World!"(你好,世界!)信息出现在你之前选择的 Slack 频道中: ![](https://cdn.document360.io/7c6ff534-cad3-4fc8-9583-912c4016362f/Images/Documentation/How%20To%20Integrate%20Tulip%20with%20Slack_200618862.png) ## 设置郁金香连接器 既然你已经有了 Slack webhook,我们就可以用 Tulip HTTP Connector 向其发布信息了。 在浏览器中打开 Tulip 网站,从页面顶部的应用程序菜单中选择 "连接器": ![](https://cdn.document360.io/7c6ff534-cad3-4fc8-9583-912c4016362f/Images/Documentation/How%20To%20Integrate%20Tulip%20with%20Slack_200623195.png) 在 "连接器 "页面,点击右上角的 "创建连接器",然后填写新 Slack 连接器的详细信息: ![](https://cdn.document360.io/7c6ff534-cad3-4fc8-9583-912c4016362f/Images/Documentation/How%20To%20Integrate%20Tulip%20with%20Slack_200624264.png) 在新的连接器中,选择您的连接,连接最初将显示为 "脱机": ![](https://cdn.document360.io/7c6ff534-cad3-4fc8-9583-912c4016362f/Images/Documentation/How%20To%20Integrate%20Tulip%20with%20Slack_200625768.png) 编辑连接详细信息,将主机设置为[hooks.slack.com](http://hooks.slack.com),将 TLS 设置为 "是": ![](https://cdn.document360.io/7c6ff534-cad3-4fc8-9583-912c4016362f/Images/Documentation/How%20To%20Integrate%20Tulip%20with%20Slack_200627024.png) 点击 "Test(测试)"检查连接,测试通过后点击 "Save(保存)": ![](https://cdn.document360.io/7c6ff534-cad3-4fc8-9583-912c4016362f/Images/Documentation/How%20To%20Integrate%20Tulip%20with%20Slack_200627264.png) 现在您的连接应显示为 "ONLINE": ![](https://cdn.document360.io/7c6ff534-cad3-4fc8-9583-912c4016362f/Images/Documentation/How%20To%20Integrate%20Tulip%20with%20Slack_200627354.png) 接下来,点击右上角的 "创建函数",设置您将在郁金香应用程序中调用的函数,以发送信息。 给函数起一个有用的名字,请求类型选择 "POST"。在 URL 栏中,粘贴以 "services/... "开头的 Slack webhook 结尾。 ![](https://cdn.document360.io/7c6ff534-cad3-4fc8-9583-912c4016362f/Images/Documentation/How%20To%20Integrate%20Tulip%20with%20Slack_200628931.png) 在 "输入 "面板下,添加名为 "消息 "的文本输入。也可以加入一个测试值: ![](https://cdn.document360.io/7c6ff534-cad3-4fc8-9583-912c4016362f/Images/Documentation/How%20To%20Integrate%20Tulip%20with%20Slack_200629224.png) 在请求配置面板中,将 "请求正文内容类型 "设置为 JSON,然后使用 "+"按钮在根下面添加一个项目。将该项的键设置为 "text",值设置为上一步中定义的 "message "输入。 ![](https://cdn.document360.io/7c6ff534-cad3-4fc8-9583-912c4016362f/Images/Documentation/How%20To%20Integrate%20Tulip%20with%20Slack_200629478.png) 现在,你可以点击右上角的 "Test(测试)"按钮来验证你的函数是否有效。你应该会在测试结果面板中看到一个简单的 "200 OK "响应,而你的测试输入应该会作为消息出现在你的 Slack 频道中: ![](https://cdn.document360.io/7c6ff534-cad3-4fc8-9583-912c4016362f/Images/Documentation/How%20To%20Integrate%20Tulip%20with%20Slack_200630080.png) ![How To Integrate Tulip with Slack](https://cdn.document360.io/7c6ff534-cad3-4fc8-9583-912c4016362f/Images/Documentation/How%20To%20Integrate%20Tulip%20with%20Slack_200628804.png) 成功测试功能后,点击右上角的 "保存更改 "按钮。 ![](https://cdn.document360.io/7c6ff534-cad3-4fc8-9583-912c4016362f/Images/Documentation/How%20To%20Integrate%20Tulip%20with%20Slack_200630644.png) ## 从应用程序发送消息 现在,我们可以在 Tulip 应用程序中使用我们的功能了。打开一个现有的应用程序或创建一个新的应用程序进行测试: ![](https://cdn.document360.io/7c6ff534-cad3-4fc8-9583-912c4016362f/Images/Documentation/How%20To%20Integrate%20Tulip%20with%20Slack_200631154.png) 在选定的步骤中添加一个按钮,然后为该按钮添加一个触发器,以运行连接器函数: ![](https://cdn.document360.io/7c6ff534-cad3-4fc8-9583-912c4016362f/Images/Documentation/How%20To%20Integrate%20Tulip%20with%20Slack_200632032.png) ![How To Integrate Tulip with Slack](https://cdn.document360.io/7c6ff534-cad3-4fc8-9583-912c4016362f/Images/Documentation/How%20To%20Integrate%20Tulip%20with%20Slack_200631792.png) 在上面的示例中,我们将 "消息 "输入设置为一个简单的静态文本值,但你也可以在文本中插入字段以提供更多信息(或使用变量): ![](https://cdn.document360.io/7c6ff534-cad3-4fc8-9583-912c4016362f/Images/Documentation/How%20To%20Integrate%20Tulip%20with%20Slack_200633005.png) 在本例中,我们使用了一些特殊字符(如 * 和 >)来格式化最终信息。有关格式化 Slack 消息的更多信息,请参阅[应用程序表面的文本格式](https://api.slack.com/reference/surfaces/formatting)。 保存触发器,然后运行应用程序并单击按钮测试功能。如果一切顺利,你会看到 Slack 频道中出现一条信息,其中包含你在触发器中选择的信息: ![](https://cdn.document360.io/7c6ff534-cad3-4fc8-9583-912c4016362f/Images/Documentation/How%20To%20Integrate%20Tulip%20with%20Slack_200633735.png) 成功!现在,您可以直接从 Tulip 应用程序向 Slack 发送警报、更新和其他类型的消息,充分利用两个平台的优势。 **注意:**Slack 应用程序网络钩子是针对特定频道的,但如果您想发布到多个频道,可以在您的 Slack 应用程序中添加额外的网络钩子,然后在连接器中创建新函数,发布到每个频道。 你甚至可以将网络钩子 URL 存储在一个变量中,并将其作为连接器函数的输入,以确定消息发布到哪个频道!