> ## 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="任意の Slack チャンネルで /dana と入力すると、自然な英語でデータベースに問い合わせできます。" prompt="/dana 獲得チャネル別に見たサインアップの前週比成長率は？" category="データ & アナリティクス" features="連携, MCP" agent="dana" />

<div className="uc-detail-wrapper">
  <Tip>手動で設定したくない場合は、このページへのリンクを Devin のセッションに貼り付けて、すべて設定するよう依頼してください。</Tip>

  <Steps>
    <Step title="MCP Marketplace でデータベースを接続する">
      Dana が質問に答えるには、少なくとも 1 つのデータベースへのアクセスが必要です。**Settings > [MCP Marketplace](/ja/work-with-devin/mcp)** に移動し、データベース用 MCP を有効化します:

      | Data source     | MCP name   | What you'll need                  |
      | --------------- | ---------- | --------------------------------- |
      | Amazon Redshift | Redshift   | ホスト、ポート、データベース、ユーザー名、パスワード        |
      | Google BigQuery | BigQuery   | OAuth (ワンクリック) またはサービス アカウント JSON |
      | PostgreSQL      | PostgreSQL | 接続文字列                             |
      | MySQL           | MySQL      | 接続文字列                             |
      | Snowflake       | Snowflake  | アカウント、ユーザー名、パスワード                 |

      MCP カードで **Enable** をクリックし、認証情報を入力してから **Test listing tools** をクリックして、接続が正しく機能することを確認します。複数のデータベースを接続でき、Dana は質問内容に応じて関連するものを自動的にクエリします。
    </Step>

    <Step title="/dana で最初の質問をする">
      [Dana](/ja/work-with-devin/data-analyst) は Devin のデータアナリストモードです。データベースへのクエリ、チャートの作成、ビジネス上の質問への自然文での回答に最適化されたツールとプロンプトを備えた特化エージェントです。

      [Devin がインストールされている](/ja/integrations/slack) 任意の Slack チャンネルを開き、`/dana` に続けて自然な英語の質問を入力します。ワークスペースで `/dana` スラッシュコマンドが使えない場合は、`@Devin !dana ...` も利用できます — どちらも同じように動作します。Dana はセッションを作成し、SQL を作成して実行し、スレッド内で返信します。

      <PromptBlock agent="dana">
        ```txt Ask Dana a question theme={null}
        /dana What were our top 10 customers by revenue last quarter?
        ```
      </PromptBlock>

      また、Devin をメンションして `!dana` マクロを使うことでも Dana を呼び出せます:

      <PromptBlock agent="dana">
        ```txt Use the !dana macro theme={null}
        @Devin !dana How many active users do we have per plan tier this month?
        ```
      </PromptBlock>

      Dana は Slack のスレッド内で、フォーマットされたテーブルや件数、そして必要に応じて結果の簡潔な解釈を返します。BI ツールに切り替える必要はありません。

      Dana は簡単な参照クエリに限られず、包括的なレポートや深掘り分析にも適しています。トレンドの調査、データのセグメント化、複数クエリにまたがる結果の統合まで依頼できます:

      <PromptBlock agent="dana">
        ```txt Deep analysis theme={null}
        /dana Conduct a deep investigation on our user growth over the past
        month. Which user segments and use cases can the growth be attributed
        to? Is it more growth in existing accounts (expansion) or top of
        funnel (new signups)? Break it down by acquisition channel and plan
        tier, and highlight any notable changes compared to the prior month.
        ```
      </PromptBlock>
    </Step>

    <Step title="Dana にスキーマとルールを教える">
      Dana はすぐに使えますが、スキーマやビジネス上の定義を理解していると精度が大きく向上します。Knowledge エントリを手動で追加する代わりに、Slack や Web アプリケーション上で Dana に直接フィードバックを与え、「次回のために覚えておいて」と伝えてください:

      * *「'active user' とは、過去 30 日間に `analytics.events` に少なくとも 1 件のイベントがあるユーザーを意味することを覚えておいて。」*
      * *「すべてのタイムスタンプは UTC で保存されています。表示するときは常に America/New\_York に変換してください。」*
      * *「`billing.subscriptions.mrr` はドルではなくセント単位です。売上を表示するときは 100 で割ってください。」*
      * *「Knowledge を更新して: `plan` カラムの値は basic/premium ではなく、free、pro、enterprise です。」*

      Dana は自身の Knowledge を一覧表示および更新できるため、修正内容は時間とともに蓄積されていきます。カラムの意味、enum の値、タイムゾーンのルール、ビジネス定義など、フィードバックを与えれば与えるほど、将来のクエリで Dana が追加で聞き返す必要が少なくなります。
    </Step>

    <Step title="同じスレッドでフォローアップ質問をする">
      Dana は Slack スレッド内でコンテキストを保持するため、フォローアップ質問では、前の結果を繰り返さずに参照できます。

      <PromptBlock agent="dana">
        ```txt Follow up on results theme={null}
        Break that down by plan tier and show the month-over-month trend.
        ```
      </PromptBlock>

      <PromptBlock agent="dana">
        ```txt Request a visualization theme={null}
        Can you chart daily signups for the past 90 days with a 7-day moving average?
        ```
      </PromptBlock>

      定期的に行う質問については、望むクエリと書式を正確に含んだ [playbook](/ja/product-guides/creating-playbooks) を作成し、Slack からカスタム `!macro` で起動することも検討してください。
    </Step>
  </Steps>
</div>
