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

# Slack Integration

> Send notifications and messages to Slack

## What is Slack?

Slack is a team communication platform. You can integrate it with your app to send notifications, alerts, and messages directly to your Slack channels.

**Perfect for:**

* Team notifications (new orders, signups, errors)
* Alert messages (payment received, system down)
* Daily reports and summaries
* Customer support alerts
* Monitoring and logging

## What You'll Need

<Steps>
  <Step title="Slack Workspace">
    You need access to a Slack workspace
  </Step>

  <Step title="Create Slack App">
    Set up a simple Slack app
  </Step>

  <Step title="Get Webhook URL">
    Get your incoming webhook URL
  </Step>

  <Step title="A good initial prompt">
    Read on for clarity
  </Step>
</Steps>

<Tip>
  Here's a helpful video to get you started.
</Tip>

<iframe src="https://www.youtube.com/embed/q1oeHAByCEM" title="YouTube video player" frameborder="0" className="w-full aspect-video rounded-xl" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen />

## Step 1: Create a Slack App

### Create the App

1. Go to [api.slack.com/apps](https://api.slack.com/apps)
2. Click **Create New App**
3. Choose **From scratch**
4. Fill in:
   * **App Name:** Your app name (like "My App Notifications")
   * **Workspace:** Choose your Slack workspace
5. Click **Create App**

### Enable Incoming Webhooks

1. In your app settings, click **Incoming Webhooks**
2. Toggle **Activate Incoming Webhooks** to **On**
3. Scroll down and click **Add New Webhook to Workspace**
4. Choose which channel to post to (like `#general` or `#notifications`)
5. Click **Allow**

### Get Your Webhook URL

You'll see a **Webhook URL** that looks like:

```
https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXX
```

**Copy this URL!** This is what you'll give to the agent.

<Warning>
  **Keep this URL secret!** Anyone with it can post to your Slack channel.
</Warning>

## Step 2: Tell the Agent What You Want

Describe what notifications you need:

### Example 1: New User Signup Notifications

```
I want Slack notifications when users sign up.

Slack Webhook URL: https://hooks.slack.com/services/T.../B.../XXX

When a new user signs up, send message to Slack with:
- User's name
- Email
- Signup time
- Link to their profile (if applicable)

Message format:
"🎉 New signup! John Doe (john@example.com) just joined!"

Please set this up.
```

### Example 2: Order Notifications

```
Send Slack alerts for new orders.

Slack Webhook URL: https://hooks.slack.com/services/T.../B.../XXX

When someone places an order, notify Slack with:
- Customer name
- Order total
- Items ordered
- Order ID

Make the message formatted and easy to read.

Please set this up.
```

### Example 3: Error Monitoring

```
I need error alerts in Slack.

Slack Webhook URL: https://hooks.slack.com/services/T.../B.../XXX

When an error occurs in my app:
- Send alert to Slack
- Include error message
- Include which page/feature
- Timestamp
- Severity level (color-coded: red for critical)

Please build this.
```

### Example 4: Daily Summary Reports

```
Send daily summary to Slack every morning.

Slack Webhook URL: https://hooks.slack.com/services/T.../B.../XXX

Every day at 9 AM, send message with:
- Total new signups (yesterday)
- Total revenue
- Number of orders
- Top selling item

Format it nicely with emojis and sections.

Please set this up.
```

<Tip>
  **That's it!** The agent will handle sending messages to Slack when events happen.
</Tip>

## Step 3: Test Your Integration

After setup:

<Steps>
  <Step title="Click Preview">
    In Emergent, click **Preview**
  </Step>

  <Step title="Trigger the Event">
    Do whatever should trigger the notification:

    * Sign up a test user
    * Place a test order
    * Trigger an error
  </Step>

  <Step title="Check Slack">
    Go to your Slack workspace

    Check the channel you selected

    You should see the notification!
  </Step>

  <Step title="Verify Message">
    Make sure the message has:

    * Correct information
    * Good formatting
    * Emojis (if you wanted them)
  </Step>
</Steps>

## Message Formatting Tips

### Use Emojis for Visual Impact

```
Tell the agent:
"Use these emojis in messages:
- 🎉 for new signups
- 💰 for payments
- ⚠️ for warnings
- 🔴 for errors
- ✅ for success"
```

### Color-Coded Messages

```
Tell the agent:
"Make Slack messages color-coded:
- Green for success (payments, signups)
- Yellow for warnings
- Red for errors
- Blue for info"
```

### Rich Formatting

```
Tell the agent:
"Format Slack messages with:
- Bold text for important info
- Bullet points for lists
- Links to relevant pages
- Sections for organization"
```

## Common Questions

<AccordionGroup>
  <Accordion title="Is Slack integration free?">
    **Yes!** Slack's incoming webhooks are completely free.

    No API limits for basic notifications.

    Perfect for all apps!
  </Accordion>

  <Accordion title="Can I send to multiple channels?">
    Yes! Create multiple webhooks. Tell the agent:

    ```
    I have multiple Slack channels:

    Webhook 1 (sales): https://hooks.slack.com/.../XXX
    Webhook 2 (support): https://hooks.slack.com/.../YYY
    Webhook 3 (errors): https://hooks.slack.com/.../ZZZ

    Send new orders to #sales
    Send support tickets to #support
    Send errors to #errors
    ```
  </Accordion>

  <Accordion title="Can I send images in messages?">
    Yes! Tell the agent:

    ```
    When sending order notifications to Slack,
    include product images in the message.

    Make it look nice and visual.
    ```
  </Accordion>

  <Accordion title="What about interactive buttons?">
    For interactive features (buttons, menus), you need the Slack API.

    Tell the agent:

    ```
    I want Slack messages with buttons:
    - "Approve" button
    - "Reject" button

    When clicked, update in my app.

    Please use Slack API for this.
    ```

    (Requires more setup than basic webhooks)
  </Accordion>
</AccordionGroup>

## Something Not Working?

### Messages Not Appearing

**Tell the agent:**

```
Slack messages aren't being sent.
Events are triggering but nothing appears in Slack.

My webhook URL: https://hooks.slack.com/.../XXX

Can you debug this?
```

### Wrong Channel

**Tell the agent:**

```
Messages going to wrong Slack channel.
They should go to #notifications but going to #general.

Can you create a new webhook for the right channel?
```

### Message Format Broken

**Tell the agent:**

```
Slack messages look messy.
Can you format them better with:
- Line breaks
- Bold text for titles
- Organized sections
```

***

## Real Examples

### Example 1: E-commerce Monitoring

```
Complete e-commerce Slack notifications.

Slack webhooks:
- Sales channel: https://hooks.slack.com/.../XXX
- Inventory channel: https://hooks.slack.com/.../YYY

Notifications to send:
1. New order placed (to #sales)
   - Customer info
   - Order details
   - Total amount

2. Low inventory alert (to #inventory)
   - When product stock < 5
   - Product name and current stock

3. Payment failed (to #sales)
   - Customer name
   - Reason for failure

Please set all this up.
```

### Example 2: SaaS App Monitoring

```
Monitor my SaaS app via Slack.

Slack webhook: https://hooks.slack.com/.../XXX

Send notifications for:
- New trial signup (🎉)
- Trial converted to paid (💰)
- User cancelled subscription (😔)
- Critical error occurred (🚨)
- Daily active users summary (every evening)

Make messages informative and emoji-rich.

Please build this.
```

### Example 3: Customer Support System

```
Customer support alerts in Slack.

Slack webhook: https://hooks.slack.com/.../XXX

When customer submits support ticket:
- Alert in Slack immediately
- Include customer name and email
- Show their issue/question
- Priority level (high/medium/low)
- Link to ticket in app

High priority tickets should be red-colored.

Please set this up.
```

## Advanced Features

### Slack API (Beyond Webhooks)

For more advanced features, tell the agent:

```
I need advanced Slack integration using Slack API.

Features:
- Send direct messages to specific users
- Read messages from channel
- Add reactions to messages
- Update existing messages
- Interactive buttons

I'll provide:
- Slack Bot Token
- Channel IDs
- Other credentials needed

Please set this up.
```

**Getting Slack API Access:**

1. In your Slack app settings
2. Go to **OAuth & Permissions**
3. Add required scopes
4. Install app to workspace
5. Copy **Bot User OAuth Token**

### Slash Commands

```
Create Slack slash command for my app.

Command: /check-status

When someone types /check-status in Slack:
- App checks current system status
- Returns formatted message with:
  - Server status
  - Database status
  - Recent errors
  - Uptime

Please build this.
```

### Two-Way Communication

```
Enable two-way Slack communication:

When ticket created in app → Send to Slack
When team replies in Slack thread → Update ticket in app

Keep everything in sync.

Please set this up.
```

## Multiple Workspaces

If you have multiple Slack workspaces:

```
I need to send to different Slack workspaces:

Workspace 1 (Company A):
Webhook: https://hooks.slack.com/.../AAA
For: Client A orders and issues

Workspace 2 (Company B):
Webhook: https://hooks.slack.com/.../BBB
For: Client B orders and issues

Route messages to correct workspace based on client.

Please set this up.
```

## Scheduling Slack Messages

### Daily Reports

```
Send daily report to Slack every day at 9 AM.

Slack webhook: https://hooks.slack.com/.../XXX

Report should include:
- Yesterday's stats (signups, revenue, orders)
- Top performing items
- Any issues or alerts
- Nice formatting with sections

Schedule this daily.
```

### Weekly Summaries

```
Send weekly summary every Monday at 9 AM.

Include:
- Last week's total revenue
- New customers count
- Best selling products
- Charts/graphs (if possible)

To Slack webhook: https://hooks.slack.com/.../XXX
```

## Message Templates

### Simple Text

```
Message format:
"New user signup: [name] ([email])"
```

### Formatted with Sections

```
Message format:
"
🎉 New Order Received!

Customer: John Doe
Email: john@example.com
Order ID: #12345
Total: $99.00

Items:
• Product A (x2) - $50.00
• Product B (x1) - $49.00

View Order: [link]
"
```

### With Attachments (Rich Format)

```
Use Slack message attachments:
- Title: "New Support Ticket"
- Color: Orange
- Fields:
  - Customer: John Doe
  - Priority: High
  - Category: Technical Issue
- Footer: Received at [timestamp]
- Button: View Ticket
```

## Best Practices

1. **Use descriptive messages** - Include all important info
2. **Add emojis** - Makes messages easier to scan
3. **Include links** - Link to relevant pages in your app
4. **Color-code by importance** - Red for urgent, green for good news
5. **Don't spam** - Batch notifications if needed

### Avoid This

1. **Too many notifications** - Will annoy your team
2. **Unclear messages** - "Something happened" isn't helpful
3. **Missing context** - Always include relevant details
4. **No links** - Make it easy to take action
5. **Plain text only** - Use formatting and emojis

## Rate Limiting

Slack has generous limits, but if sending many messages:

```
Tell the agent:
"I'm sending many Slack notifications.
Can you add rate limiting so we don't hit Slack's limits?

Batch notifications if needed:
- Collect for 5 minutes
- Send one summary message
Instead of individual messages."
```

## Troubleshooting Guide

### Common Errors

**"Invalid webhook URL"**

* Check you copied the full URL
* Make sure it starts with `https://hooks.slack.com/services/`

**"Messages delayed"**

* Might be network issues
* Check your server logs

**"Messages not formatted"**

* Need to use proper Slack formatting
* Ask agent to use Slack's block kit

## Quick Checklist

Before going live, check that you have:

* Created Slack app
* Got webhook URL
* Tested sending messages
* Messages appear in correct channel
* Formatting looks good
* Emojis working
* Links clickable
* Not too many notifications

## Remember

**Completely free** - No API costs

**Easy to set up** - Just need webhook URL

**Great for teams** - Keep everyone informed

**Rich formatting** - Make messages beautiful

**No rate limits (reasonable use)** - Send lots of messages

**Multiple channels** - Create multiple webhooks

<Info>
  **Quick start:** Get your webhook URL from Slack and tell the agent what notifications you want. Works in 5 minutes!
</Info>

## Need Help?

### Can't Find Webhook URL

```
In Slack app settings:
1. Click "Incoming Webhooks"
2. Scroll to bottom
3. Look for "Webhook URLs for Your Workspace"
4. Copy the URL

If you don't see it:
- Make sure webhooks are activated (toggle at top)
- Add new webhook to workspace
```

### Want to Change Channel

```
Create a new webhook for the new channel:
1. In Slack app → Incoming Webhooks
2. Click "Add New Webhook to Workspace"
3. Choose new channel
4. Get new URL

Tell agent: "Use this new webhook URL: [paste URL]"
```

### Messages Too Frequent

```
Tell the agent:
"Slack messages are too frequent. Can you:
1. Batch them together
2. Send summary every 5 minutes
3. Only send if more than 5 events
Instead of one message per event."
```

<Tip>
  **Pro tip:** Start with simple notifications, then add more as needed. It's better to add features gradually than to spam your Slack with too many alerts!
</Tip>
