# 创建自定义自动化 (/zh/automations/create)

<!-- agent-signals: reading_time_min: 3 · est_tokens: 1573 · updated: 2026-09-23 -->
Related: [用于 agent 和自动化的集成](/zh/automations/integrations.md), [管理自动化](/zh/automations/manage.md), [预定义自动化](/zh/automations/reference.md), [安全联系人](/zh/dashboard/security-contact.md)

自定义自动化使用你编写的指令，按计划、在仓库推送时、在已连接的集成事件发生时或在收到 webhook 请求时运行 agent。当[预定义自动化](/zh/automations/reference)无法覆盖你需要的行为，或者你希望将自己的提示词与特定的上下文仓库和集成组合在一起时，使用自定义自动化。有关所有自动化共享的触发器、更新模式和配置选项的概述，请参见[自动化](/zh/automations)。

<div id="prerequisites">
  ## 前置条件 [#前置条件]
</div>

* [Pro 或 Enterprise 计划](https://mintlify.com/pricing?ref=automations)。集成（Integration）触发器需要 Enterprise 计划。
* 一个已连接到 GitHub 或 GitLab 仓库的 Mintlify 项目
* 对于 GitHub：在你计划用于自动化的每个仓库上都安装 [Mintlify GitHub 应用](/zh/deploy/github)
* 对于 GitLab：已连接的 GitLab 账户（请参见下方[GitLab 设置](#gitlab-setup)）

<div id="create-a-custom-automation">
  ## 创建自定义自动化 [#创建自定义自动化]
</div>

<Note>
  agent 运行在受限互联网访问的隔离沙箱中。它无法在运行时安装额外的包或工具。引用不可用工具的提示词可能产生意外结果或失败。
</Note>

1. 在控制台中打开 [Automations](https://app.mintlify.com/products/automations) 页面。
2. 点击 **New automation**。
3. 在配置页面上，设置自动化名称、触发器、提示词、上下文仓库、集成和更新模式。有关各字段的详细说明，请参见[配置](/zh/automations/manage#configurations)。
4. 点击 **Save**。

<Tip>
  你也可以让 [Slack 中的 agent](/zh/agent/slack#manage-automations) 为你创建自动化，只需描述你希望该自动化执行的操作。
</Tip>

<div id="write-effective-instructions">
  ## 撰写有效的指令 [#撰写有效的指令]
</div>

有效的自动化指令聚焦于单一任务，并定义清晰、可验证的结果。由于 agent 是非确定性的，自动化结果会有所差异，但格式良好的指令能产生更一致的结果。

* **描述结果。** 告诉 agent 一次成功的运行应该是什么样的。
* **撰写流程。** 给 agent 一份按步骤执行的指南。
* **保持范围窄。** 将复杂任务拆分到多个自动化中，而不是合并到一个提示词里。

更多示例和模式请参见[使用自动化](/zh/guides/use-automations)。

<div id="test-your-automation">
  ## 测试你的自动化 [#测试你的自动化]
</div>

通过手动运行来测试新的自动化，这样就无需等待其触发器发生。手动运行使用自动化的当前配置，并与自动运行一起显示在运行历史中。使用集成或 webhook 触发器的自动化无法手动运行；请改为发送事件或 webhook 请求。要为测试运行选择范围，请参见[手动运行自动化](/zh/automations/manage#run-an-automation-manually)。

在[运行历史](/zh/automations/manage#view-run-history)中审查该次运行，查看提示词、agent 更改的文件以及它打开的任何拉取请求。如果结果不符合预期，请更新你的指令并再次运行。

## GitLab 设置 [#gitlab-设置]

要在自动化中使用 GitLab 仓库，请通过 [GitLab OAuth](https://app.mintlify.com/settings/organization/gitlab-oauth) 设置页面连接每个项目。请连接自动化涉及的所有仓库——你的文档仓库以及任何触发或上下文仓库。你必须在每个项目中至少具有 Maintainer 角色。

<Note>
  自动化需要付费的 GitLab 套餐。代理使用短期项目访问令牌来访问仓库，GitLab 的 Free 套餐不支持此功能。
</Note>

<div id="edit-a-custom-automation">
  ## 编辑自定义自动化 [#编辑自定义自动化]
</div>

1. 在控制台中打开 [Automations](https://app.mintlify.com/products/automations) 页面。
2. 点击自动化卡片上的 <Icon icon="<svg xmlns=&#x22;http://www.w3.org/2000/svg&#x22; viewBox=&#x22;0 0 24 24&#x22; fill=&#x22;none&#x22;><path d=&#x22;M15.5 12C15.5 13.933 13.933 15.5 12 15.5C10.067 15.5 8.5 13.933 8.5 12C8.5 10.067 10.067 8.5 12 8.5C13.933 8.5 15.5 10.067 15.5 12Z&#x22; stroke=&#x22;currentColor&#x22; stroke-width=&#x22;1.5&#x22;/><path d=&#x22;M21.011 14.0965C21.5329 13.9558 21.7939 13.8854 21.8969 13.7508C22 13.6163 22 13.3998 22 12.9669V11.0332C22 10.6003 22 10.3838 21.8969 10.2493C21.7938 10.1147 21.5329 10.0443 21.011 9.90358C19.0606 9.37759 17.8399 7.33851 18.3433 5.40087C18.4817 4.86799 18.5509 4.60156 18.4848 4.44529C18.4187 4.28902 18.2291 4.18134 17.8497 3.96596L16.125 2.98673C15.7528 2.77539 15.5667 2.66972 15.3997 2.69222C15.2326 2.71472 15.0442 2.90273 14.6672 3.27873C13.208 4.73448 10.7936 4.73442 9.33434 3.27864C8.95743 2.90263 8.76898 2.71463 8.60193 2.69212C8.43489 2.66962 8.24877 2.77529 7.87653 2.98663L6.15184 3.96587C5.77253 4.18123 5.58287 4.28891 5.51678 4.44515C5.45068 4.6014 5.51987 4.86787 5.65825 5.4008C6.16137 7.3385 4.93972 9.37763 2.98902 9.9036C2.46712 10.0443 2.20617 10.1147 2.10308 10.2492C2 10.3838 2 10.6003 2 11.0332V12.9669C2 13.3998 2 13.6163 2.10308 13.7508C2.20615 13.8854 2.46711 13.9558 2.98902 14.0965C4.9394 14.6225 6.16008 16.6616 5.65672 18.5992C5.51829 19.1321 5.44907 19.3985 5.51516 19.5548C5.58126 19.7111 5.77092 19.8188 6.15025 20.0341L7.87495 21.0134C8.24721 21.2247 8.43334 21.3304 8.6004 21.3079C8.76746 21.2854 8.95588 21.0973 9.33271 20.7213C10.7927 19.2644 13.2088 19.2643 14.6689 20.7212C15.0457 21.0973 15.2341 21.2853 15.4012 21.3078C15.5682 21.3303 15.7544 21.2246 16.1266 21.0133L17.8513 20.034C18.2307 19.8187 18.4204 19.711 18.4864 19.5547C18.5525 19.3984 18.4833 19.132 18.3448 18.5991C17.8412 16.6616 19.0609 14.6226 21.011 14.0965Z&#x22; stroke=&#x22;currentColor&#x22; stroke-linecap=&#x22;round&#x22; stroke-width=&#x22;1.5&#x22;/></svg>" /> 设置按钮以打开其配置页面。
3. 更新[配置](/zh/automations/manage#configurations)中描述的任何字段。
4. 点击 **Save**。

<div id="delete-a-custom-automation">
  ## 删除自定义自动化 [#删除自定义自动化]
</div>

删除自动化是永久性的，会移除其配置和运行历史。

1. 在控制台中打开 [Automations](https://app.mintlify.com/products/automations) 页面。
2. 点击自动化卡片上的 <Icon icon="<svg xmlns=&#x22;http://www.w3.org/2000/svg&#x22; viewBox=&#x22;0 0 24 24&#x22; fill=&#x22;none&#x22;><path d=&#x22;M15.5 12C15.5 13.933 13.933 15.5 12 15.5C10.067 15.5 8.5 13.933 8.5 12C8.5 10.067 10.067 8.5 12 8.5C13.933 8.5 15.5 10.067 15.5 12Z&#x22; stroke=&#x22;currentColor&#x22; stroke-width=&#x22;1.5&#x22;/><path d=&#x22;M21.011 14.0965C21.5329 13.9558 21.7939 13.8854 21.8969 13.7508C22 13.6163 22 13.3998 22 12.9669V11.0332C22 10.6003 22 10.3838 21.8969 10.2493C21.7938 10.1147 21.5329 10.0443 21.011 9.90358C19.0606 9.37759 17.8399 7.33851 18.3433 5.40087C18.4817 4.86799 18.5509 4.60156 18.4848 4.44529C18.4187 4.28902 18.2291 4.18134 17.8497 3.96596L16.125 2.98673C15.7528 2.77539 15.5667 2.66972 15.3997 2.69222C15.2326 2.71472 15.0442 2.90273 14.6672 3.27873C13.208 4.73448 10.7936 4.73442 9.33434 3.27864C8.95743 2.90263 8.76898 2.71463 8.60193 2.69212C8.43489 2.66962 8.24877 2.77529 7.87653 2.98663L6.15184 3.96587C5.77253 4.18123 5.58287 4.28891 5.51678 4.44515C5.45068 4.6014 5.51987 4.86787 5.65825 5.4008C6.16137 7.3385 4.93972 9.37763 2.98902 9.9036C2.46712 10.0443 2.20617 10.1147 2.10308 10.2492C2 10.3838 2 10.6003 2 11.0332V12.9669C2 13.3998 2 13.6163 2.10308 13.7508C2.20615 13.8854 2.46711 13.9558 2.98902 14.0965C4.9394 14.6225 6.16008 16.6616 5.65672 18.5992C5.51829 19.1321 5.44907 19.3985 5.51516 19.5548C5.58126 19.7111 5.77092 19.8188 6.15025 20.0341L7.87495 21.0134C8.24721 21.2247 8.43334 21.3304 8.6004 21.3079C8.76746 21.2854 8.95588 21.0973 9.33271 20.7213C10.7927 19.2644 13.2088 19.2643 14.6689 20.7212C15.0457 21.0973 15.2341 21.2853 15.4012 21.3078C15.5682 21.3303 15.7544 21.2246 16.1266 21.0133L17.8513 20.034C18.2307 19.8187 18.4204 19.711 18.4864 19.5547C18.5525 19.3984 18.4833 19.132 18.3448 18.5991C17.8412 16.6616 19.0609 14.6226 21.011 14.0965Z&#x22; stroke=&#x22;currentColor&#x22; stroke-linecap=&#x22;round&#x22; stroke-width=&#x22;1.5&#x22;/></svg>" /> 设置按钮以打开其配置页面。
3. 点击页面底部的 **Delete automation** 并确认。
