> ## 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.

# Ad-Hoc Data Queries in 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="Ad-Hoc Data Queries in Slack" description="Type /dana in any Slack channel to query your database in plain English." prompt="/dana What was our week-over-week signup growth, broken down by acquisition channel?" category="Data & Analytics" features="Integrations, MCP" agent="dana" />

<div className="uc-detail-wrapper">
  <Tip>Don't want to set this up manually? Paste a link to this page into a Devin session and ask it to set everything up for you.</Tip>

  <Steps>
    <Step title="Connect a database in the MCP Marketplace">
      Dana needs access to at least one database to answer questions. Go to **Settings > [MCP Marketplace](/work-with-devin/mcp)** and enable a database MCP:

      | Data source     | MCP name   | What you'll need                          |
      | --------------- | ---------- | ----------------------------------------- |
      | Amazon Redshift | Redshift   | Host, port, database, username, password  |
      | Google BigQuery | BigQuery   | OAuth (one-click) or service account JSON |
      | PostgreSQL      | PostgreSQL | Connection string                         |
      | MySQL           | MySQL      | Connection string                         |
      | Snowflake       | Snowflake  | Account, username, password               |

      Click **Enable** on the MCP card, fill in your credentials, then click **Test listing tools** to confirm the connection works. You can connect multiple databases — Dana will query whichever one is relevant to your question.
    </Step>

    <Step title="Ask your first question with /dana">
      [Dana](/work-with-devin/data-analyst) is Devin's data analyst mode — a specialized agent with tools and prompts optimized for querying databases, building charts, and answering business questions in plain English.

      Open any Slack channel where [Devin is installed](/integrations/slack) and type `/dana` followed by a plain-English question. If the `/dana` slash command isn't available in your workspace, you can also use `@Devin !dana ...` — both work the same way. Dana creates a session, writes the SQL, runs it, and replies in-thread.

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

      You can also invoke Dana by mentioning Devin with the `!dana` macro:

      <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 responds directly in the Slack thread with formatted tables, counts, and — when useful — a short interpretation of the results. No context-switching to a BI tool required.

      Dana isn't limited to quick lookups — it's also great at comprehensive reports and deep analysis. Ask it to investigate trends, segment data, and synthesize findings across multiple queries:

      <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="Teach Dana your schema and conventions">
      Dana works out of the box, but it gets significantly better when it knows your schema and business definitions. Instead of manually adding Knowledge entries, just give Dana feedback directly — in Slack or the webapp — and ask it to remember things for next time:

      * *"Remember that 'active user' means at least one event in `analytics.events` in the past 30 days."*
      * *"All our timestamps are stored in UTC. Always convert to America/New\_York for display."*
      * *"`billing.subscriptions.mrr` is in cents, not dollars. Divide by 100 when showing revenue."*
      * *"Update your knowledge: the `plan` column values are free, pro, and enterprise — not basic/premium."*

      Dana can list and update its own Knowledge, so corrections compound over time. The more feedback you give — column meanings, enum values, timezone rules, business definitions — the fewer follow-up questions Dana needs to ask in future queries.
    </Step>

    <Step title="Ask follow-ups in the same thread">
      Dana keeps context within a Slack thread, so follow-up questions can reference earlier results without repeating yourself.

      <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>

      For questions you ask regularly, consider creating a [playbook](/product-guides/creating-playbooks) with the exact queries and formatting you want, then trigger it with a custom `!macro` from Slack.
    </Step>
  </Steps>
</div>
