> ## Documentation Index
> Fetch the complete documentation index at: https://docs.devin.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Slack 中的客户健康概览

export const UseCaseHero = ({title, description, prompt, category, features, devinUrl, agent, intent, playbookId, type}) => {
  const encodedPrompt = encodeURIComponent(prompt || '');
  const tag = 'docs-use-case-gallery';
  const utm = 'utm_source=docs&utm_medium=use-case-gallery&utm_campaign=hero-cta';
  const agentParams = (agent ? '&agent=' + agent : '') + (intent ? '&intent=' + intent : '') + (playbookId ? '&playbookId=' + playbookId : '');
  const devinHref = type === 'schedule' ? 'https://app.devin.ai/settings/schedules/create?' + utm + agentParams + (prompt ? '&prompt=' + encodedPrompt : '') : type === 'review' ? 'https://app.devin.ai/review?' + utm : agent === 'ada' ? 'https://app.devin.ai/search?' + utm + '&noSubmit=true' + (prompt ? '&prompt=' + encodedPrompt : '') : devinUrl ? devinUrl.includes('?') ? devinUrl + '&' + utm + agentParams : devinUrl + '?' + utm + agentParams : prompt ? 'https://app.devin.ai/?tags=' + tag + '&' + utm + agentParams + '&prompt=' + encodedPrompt : 'https://app.devin.ai/?' + utm + agentParams;
  const buttonLabel = type === 'schedule' ? 'Schedule in Devin ↗' : type === 'review' ? 'Set Up Devin Review ↗' : agent === 'advanced' ? 'Try in Devin ↗' : agent === 'dana' ? 'Try in Dana ↗' : agent === 'ada' ? 'Try in Ask Devin ↗' : 'Try in Devin ↗';
  const featureList = features ? features.split(',').map(f => f.trim()) : [];
  return <div className="uc-hero">
      <div className="uc-hero-inner">
        <div className="uc-hero-left">
          <h1 className="uc-hero-title">{title}</h1>
          <p className="uc-hero-desc">{description}</p>
          <div>
            <a href={devinHref} target="_blank" rel="noopener noreferrer" className="try-in-devin-btn">
              {buttonLabel}
            </a>
          </div>
        </div>
        <div className="uc-hero-meta">
          <div className="uc-meta-item">
            <span className="uc-meta-label">Author</span>
            <span className="uc-meta-value">Cognition</span>
          </div>
          <div className="uc-meta-item">
            <span className="uc-meta-label">Category</span>
            <span className="uc-meta-value">{category}</span>
          </div>
          {featureList.length > 0 && <div className="uc-meta-item">
              <span className="uc-meta-label">Features</span>
              <span className="uc-meta-value">{featureList.join(', ')}</span>
            </div>}
        </div>
      </div>
    </div>;
};

export const PromptBlock = ({children, type, agent, intent, playbookId}) => {
  var utm = 'utm_source=docs&utm_medium=use-case-gallery&utm_campaign=prompt-block';
  var tag = 'docs-use-case-gallery';
  var agentParams = (agent ? '&agent=' + agent : '') + (intent ? '&intent=' + intent : '') + (playbookId ? '&playbookId=' + playbookId : '');
  var label = type === 'schedule' ? 'Schedule in Devin' : type === 'playbook' ? 'Create Playbook' : type === 'knowledge' ? 'Add to Knowledge' : agent === 'advanced' ? 'Try in Devin' : agent === 'dana' ? 'Try in Dana' : agent === 'ada' ? 'Try in Ask Devin' : 'Try in Devin';
  var buildUrl = function (text) {
    var encoded = encodeURIComponent(text);
    if (type === 'schedule') return 'https://app.devin.ai/settings/schedules/create?' + utm + agentParams + '&prompt=' + encoded;
    if (type === 'playbook') return 'https://app.devin.ai/settings/playbooks/create?' + utm + '&body=' + encoded;
    if (type === 'knowledge') return 'https://app.devin.ai/knowledge?' + utm + '&body=' + encoded;
    if (agent === 'ada') return 'https://app.devin.ai/search?' + utm + '&noSubmit=true&prompt=' + encoded;
    return 'https://app.devin.ai/?tags=' + tag + '&' + utm + agentParams + '&prompt=' + encoded;
  };
  const ref = React.useRef(null);
  const [href, setHref] = React.useState('#');
  React.useEffect(() => {
    if (!ref.current) return;
    var codeEl = ref.current.querySelector('pre code');
    if (codeEl) {
      var text = codeEl.textContent.trim();
      if (text) setHref(buildUrl(text));
    }
    var header = ref.current.querySelector('[data-component-part="code-block-header"]');
    if (header && !header.querySelector('.prompt-block-devin-link')) {
      var link = document.createElement('a');
      link.href = href;
      link.target = '_blank';
      link.rel = 'noopener noreferrer';
      link.className = 'prompt-block-devin-link';
      link.style.cssText = 'display:inline-flex;align-items:center;gap:6px;text-decoration:none;color:#fff;font-size:11px;font-weight:500;padding:4px 10px;border-radius:6px;white-space:nowrap;background:#317CFF;transition:background 0.2s;margin-left:8px;';
      link.innerHTML = '<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/><polyline points="15 3 21 3 21 9"/><line x1="10" y1="14" x2="21" y2="3"/></svg> ' + label;
      link.onmouseenter = function () {
        link.style.background = '#2968D9';
      };
      link.onmouseleave = function () {
        link.style.background = '#317CFF';
      };
      header.appendChild(link);
    }
    var existingLink = ref.current.querySelector('.prompt-block-devin-link');
    if (existingLink && href !== '#') existingLink.href = href;
  });
  return <div className="prompt-block" ref={ref}>{children}</div>;
};

<UseCaseHero title="Slack 中的客户健康摘要" description="使用 Dana 和 Playbook，从你的数据库中拉取客户账户指标，并按需在 Slack 中呈现。" prompt="@Devin !dana !customer-health 给我一份 Acme Corp 的账户概览" category="数据与分析" features="集成, Playbooks, MCP" agent="dana" />

<div className="uc-detail-wrapper">
  <Tip>不想手动配置？将本页链接粘贴到 Devin 会话中，让它帮你完成所有设置。</Tip>

  <Steps>
    <Step title="通过 MCP 将客户数据库接入">
      Dana 需要访问存放你客户数据的数据库。前往 **Settings > Connections > MCP servers**，找到你的数据库提供商，然后点击 **Enable**。

      客户指标的常见数据库配置：

      * **PostgreSQL**：用于应用数据 (用户、账户、功能开关)
      * **Redshift** 或 **BigQuery**：用于分析型数仓数据 (使用事件、收入)
      * **Snowflake**：用于同时存放运营与分析数据

      如果你的数据库提供商未在列表中，点击 **Add Your Own** 并提供连接字符串。对于生产数据库，请始终使用**只读**连接字符串，或使用权限受限的数据库用户。

      连接完成后，从 Devin Web 应用启动一个快速的 [Dana 会话](/zh/work-with-devin/data-analyst)来验证是否可用：

      <PromptBlock agent="dana">
        ```txt 验证数据库连接 theme={null}
        !dana List all tables in the analytics schema that contain the word "user" or "account"
        ```
      </PromptBlock>

      如果 Dana 返回了你的表名，则说明 MCP 集成工作正常。否则，请在 **Settings > Connections > MCP servers** 中重新检查凭据，并确保你的数据库允许来自 Devin IP 段的连接。
    </Step>

    <Step title="创建客户健康手册">
      前往 [**Settings > Playbooks > Create playbook**](https://app.devin.ai/settings/playbooks/create?utm_source=docs\&utm_medium=use-case-gallery)，并将其命名为 `!customer-health` —— `!` 前缀会将其变成一个可以在 Slack 中调用的[宏](/zh/product-guides/using-playbooks)。

      定义 Dana 在任意客户账号上应拉取的指标。保持 playbook 足够通用——Dana 会根据你的 schema 自动找出合适的表和查询：

      <PromptBlock type="playbook">
        ```txt Customer Account Health Summary theme={null}
        When given a customer name, find and report:

        1. **Monthly active users** — 6-month trend with month-over-month change
        2. **Feature adoption** — which features the account used in the past 30 days and how many distinct users per feature
        3. **Support tickets** — open vs resolved in the past 30 days, average resolution time
        4. **Revenue** — current MRR and 6-month trend

        Format the output as:
        - A summary line with health verdict (Healthy / At Risk / Needs Attention)
        - A table with MAU trend, feature adoption count, open tickets, and current MRR
        - A short list of risk factors or positive signals based on the data
        ```
      </PromptBlock>

      你也可以让 Devin 根据你的特定 schema 和指标生成一个定制的客户健康度 playbook。
    </Step>

    <Step title="在 Slack 中运行它">
      请确保你已在 **Settings > Connections** 中连接了 [Slack integration](/zh/integrations/slack)，并且已将 Devin 添加到你团队讨论客户账户的频道中。

      使用 `!dana` 关键字加上你的宏名称来触发该 playbook：

      <PromptBlock agent="dana">
        ```txt Pull customer health summary theme={null}
        @Devin !dana !customer-health Give me an account summary for Acme Corp
        ```
      </PromptBlock>

      Dana 会查询你已连接的数据库，运行来自 playbook 的 SQL，并在同一线程中回复一条格式化的摘要：

      > **Acme Corp — 存在风险**
      >
      > | 指标            | 数值                 | 趋势        |
      > | ------------- | ------------------ | --------- |
      > | 月活跃用户数 (MAU)  | 342                | -8% MoM   |
      > | 使用的功能数 (30 天) | 10 个中使用 6 个        | 稳定        |
      > | 未结支持工单数       | 12 (平均解决时间 8.2 小时) | 比上月多 3 个  |
      > | MRR (月经常性收入)  | \$4,850            | 连续 3 个月持平 |
      >
      > **风险因素：** MAU 持续下降，3 个月无扩容，最近有 3 个工单与登录失败相关。

      你可以在同一线程中继续追问，以进一步深入分析：

      <PromptBlock agent="dana">
        ```txt Drill into user activity theme={null}
        @Devin !dana For Acme Corp, show me the daily active users for the past
        30 days. Flag any days where DAU dropped below 50% of the 30-day average.
        ```
      </PromptBlock>

      <PromptBlock agent="dana">
        ```txt Compare to plan average theme={null}
        @Devin !dana Compare Acme Corp's feature adoption and MAU to the median
        for all Enterprise-plan accounts. Where are they lagging?
        ```
      </PromptBlock>
    </Step>

    <Step title="让其常态化">
      一旦这个 playbook 在处理临时查询时效果不错，就可以考虑将其自动化：

      * **计划会话**：使用[预定 Devin 会话](/zh/product-guides/scheduled-sessions)，让 Dana 每周一早上在 `#customer-health` 频道中发布前 10 个重点账户的健康状况摘要。
      * **会前准备**：在季度业务评审前，让 Dana 拉取特定层级中所有账户的摘要 —— `@Devin !dana !customer-health Run this for all accounts where plan = 'Enterprise'`。
    </Step>
  </Steps>
</div>
