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

# Slack Integration

> Use Migma from Slack through OpenClaw or a custom Slack app that prepares branded emails, preview images, and HTML files.

Use Migma from Slack through [OpenClaw](/openclaw) or your own Slack app. The Slack layer receives messages and posts replies. Migma handles brand access, email generation, preview screenshots, HTML, validation, and approved send or export actions.

Use this guide when building a Slack app around Migma, or when defining the expected Slack behavior for an OpenClaw setup.

Example Slack prompts:

* `migma create 3 emails for Stripe and show me images`
* `migma create 3 emails for this brand and give me the HTML files`
* `migma import https://stripe.com, create 3 onboarding emails, and return previews`
* `migma make these emails shorter and send me updated HTML`

<Info>
  Slack is a chat surface for Migma, not a sending provider. Slack handles workspace install and message delivery. Migma handles brand access, email generation, previews, HTML, validation, and sending or export only after approved access.
</Info>

## Recommended flow

<Steps>
  <Step title="Authenticate the Slack user">
    Ask the user to connect Migma from Slack. Use [Agent registration](/agent-registration) so the Slack app or OpenClaw agent receives its own scoped Migma key after the user approves a short code.
  </Step>

  <Step title="Resolve the brand">
    If the prompt names a brand, list the user's Migma brands and filter by name. If there is one match, set that brand's `projectId` for the request. If there are multiple matches, ask the user to choose. If no brand exists, ask for a website URL and import the brand before creating email.
  </Step>

  <Step title="Prepare the emails">
    Send the user's prompt to Migma with the selected `projectId`. Pass `count: 3` when the user asks for three emails.
  </Step>

  <Step title="Return reviewable output">
    Post each subject and preview image in the Slack thread. Attach `.html` files when the user asks for HTML.
  </Step>

  <Step title="Wait for approval">
    Keep send, schedule, export, and audience actions behind an explicit Slack confirmation.
  </Step>
</Steps>

## Auth model

Use [Agent registration](/agent-registration) for Slack apps that act for individual Migma users. Slack workspace install only lets the app receive messages and post replies. Migma access starts when the app begins the agent-auth flow, shows the user a Migma approval link, then stores the issued Migma key server-side for that Slack user.

Recommended scopes:

| Slack capability                                       | Migma scopes                        |
| ------------------------------------------------------ | ----------------------------------- |
| List brands and fetch generated output                 | Default read access or `email:read` |
| Import a missing brand, prepare emails, or edit emails | `email:send email:read`             |
| Manage brand assets, logos, or knowledge base entries  | `project:write`                     |
| Return preview screenshots                             | `email:preview`                     |
| Run preflight checks                                   | `email:validate`                    |
| Create campaign drafts or send tests                   | `campaign:write email:send`         |

<Warning>
  Do not ask users to paste a Migma API key into Slack. Use agent registration for user-approved access, or use a manually created API key only for an admin-owned internal bot where the workspace owner controls the key.
</Warning>

For protocol details, see [Agent Auth Reference](/agent-auth). For standard server-side API keys, see [Authentication](/authentication).

## Brand resolution

When a prompt says `for Stripe`, the app should choose the brand in this order:

1. Use a saved default brand for the Slack channel or user.
2. List Migma brands, filter by name, and ask the user to pick when there are multiple matches.
3. If no brand exists, ask for a website URL before importing a new brand.
4. Store the selected `projectId` only as a Slack preference. Pass it on Migma requests instead of exposing it in Slack copy.

Do not create a new brand from a name alone. Ask for a website URL or explicit confirmation before import.

## Output rules

| User asks for            | Slack should return                                                                             |
| ------------------------ | ----------------------------------------------------------------------------------------------- |
| `show me images`         | Subject lines plus preview images for each generated email.                                     |
| `give me the HTML files` | One `.html` file per generated email, named from the subject or slot number.                    |
| `create 3 emails`        | Three generated emails from one Migma generation, with one Slack thread containing all outputs. |
| `send this`              | Confirmation prompt showing recipient, sender, subject, and brand before Migma sends.           |

Migma generation results include per-email IDs, HTML, screenshot URLs, subjects, and series order. Use those per-email records when attaching files, showing images, editing one email, or sending one slot from a series.

## Slack command behavior

Keep Slack responses short and review-first:

```text theme={null}
Migma prepared 3 emails for Stripe.

1. Welcome trial users
2. Show Stripe Billing value
3. Invite upgrade review

Attached: previews and HTML files.
Next: reply "edit email 2" or "send test email 1 to me".
```

For longer work, post progress in the thread:

* `Connecting Migma`
* `Finding brand`
* `Importing brand`
* `Preparing 3 emails`
* `Rendering previews`
* `Attaching HTML`

## Safety

* Store Migma keys server-side, encrypted, and mapped to the Slack user or workspace that approved access.
* Keep Slack tokens separate from Migma tokens.
* Request only the scopes needed for the Slack action.
* Do not post API keys, raw bearer tokens, or private customer data into Slack.
* Require confirmation before sending, scheduling, exporting to another platform, or changing audiences.
* Revoke Migma access from **Settings → Developers → API Keys** when a Slack user disconnects.

## Related docs

<CardGroup cols={2}>
  <Card title="Agent Registration" icon="key" href="/agent-registration">
    Let the Slack app request scoped Migma access with a user approval code.
  </Card>

  <Card title="Agent Auth Reference" icon="robot" href="/agent-auth">
    Implement the auth.md claim flow for a Slack app.
  </Card>

  <Card title="SDK" icon="https://mintcdn.com/migmaai/kT6TJgF40rDP8_qB/images/logos/npm.svg?fit=max&auto=format&n=kT6TJgF40rDP8_qB&q=85&s=1839361b0494d7d3199cdaa3575846ac" href="/sdk" width="24" height="24" data-path="images/logos/npm.svg">
    Generate series, fetch HTML, and read screenshot URLs from server-side code.
  </Card>

  <Card title="OpenClaw" icon="chat-bubble-left-right" href="/openclaw">
    Use Migma in Slack through the OpenClaw agent.
  </Card>
</CardGroup>
