# Slack Integration Quick Start Guide

**Last Updated:** 2026-03-06

Quick reference for testing and troubleshooting the Slack integration.

## Quick Tests

### 1. Test Webhook Connectivity

```bash
php v2/scripts/affiliate/test-slack-webhook.php --verbose
```

Sandbox (optional): set `SLACK_LOOP_TEST_WEBHOOK_URL` or `test_webhook_url` in `v2/config/slack-config.local.php` so tests post to **#loop-updates-sandbox** instead of **#loop-updates**. See `docs/systems/affiliate/SLACK_LOOP_UPDATES.md` section “Sandbox channel for safe testing”.

### 2. Run Full Diagnostics

```bash
php v2/scripts/affiliate/diagnose-slack-integration.php --verbose
```

### 3. Test Partner Registration Notification

```bash
# Test email registration
php v2/scripts/affiliate/test-partner-registration-slack.php --type=email

# Test OAuth registration
php v2/scripts/affiliate/test-partner-registration-slack.php --type=oauth
```

### 4. Check Notification Status (Admin)

```bash
curl -b cookies.txt https://www.ordio.com/v2/api/slack-notification-status.php
```

## Common Issues & Quick Fixes

### Issue: No notifications appearing

**Quick check:**
```bash
# 1. Verify webhook works
php v2/scripts/affiliate/test-slack-webhook.php

# 2. Check configuration
php v2/scripts/affiliate/diagnose-slack-integration.php

# 3. Check logs
tail -f v2/logs/affiliate-slack.log
```

**Common causes:**
- Webhook URL expired → Regenerate in Slack API dashboard
- Configuration disabled → Set `SLACK_LOOP_UPDATES_ENABLED=true`
- Network/SSL issues → Check error logs

### Issue: Notifications delayed

**Check:**
- Review log file for retry attempts
- Check network connectivity
- Verify Slack API status

### Issue: Some notifications work, others don't

**Check:**
- Review payload validation errors in logs
- Verify required fields are present
- Check correlation IDs in logs

## Monitoring

### Real-time Log Monitoring

```bash
tail -f v2/logs/affiliate-slack.log
```

### Check Statistics

```php
<?php
require_once 'v2/helpers/affiliate-slack-monitor.php';
$stats = getSlackNotificationStats(24);
print_r($stats);
```

### Health Check

```bash
php v2/scripts/affiliate/health-check-slack.php
```

## Channel Name

**Important:** The channel is `#loop-updates`, not `#ordio-loop`.

When setting up the webhook in Slack API dashboard, select `#loop-updates` channel.

## Next Steps After Fix

1. ✅ Run diagnostic script
2. ✅ Test webhook connectivity  
3. ✅ Monitor next partner registration
4. ✅ Set up health check cron job
5. ✅ Review logs after 24 hours

## Related Documentation

- [SLACK_LOOP_UPDATES.md](SLACK_LOOP_UPDATES.md) - Complete integration guide
- [SLACK_TROUBLESHOOTING.md](SLACK_TROUBLESHOOTING.md) - Detailed troubleshooting
- [SLACK_MONITORING.md](SLACK_MONITORING.md) - Monitoring setup
