# Week 4 - Integrations Planning

**Goal:** Connect Jira Cloud with n8n, Slack, BigBlueButton, and Email systems

---

## Integration Architecture

```
┌─────────────────────────────────────────────────────────────┐
│                     Jira Cloud                              │
│  (4 Projects, 23 Fields, 5 Dashboards, 20+ Filters)        │
└────────────┬────────────────────────────────────────────────┘
             │ Webhooks / REST API
             ▼
┌─────────────────────────────────────────────────────────────┐
│                   n8n Orchestration                         │
│     (Main automation and routing hub)                       │
└────────┬────────────────┬────────────────┬──────────────────┘
         │                │                │
         ▼                ▼                ▼
    ┌────────┐    ┌─────────────┐    ┌──────────┐
    │ Slack  │    │ BigBlueButton│   │ Email    │
    │ Notifs │    │  Integration │   │ Handler  │
    └────────┘    └─────────────┘    └──────────┘
```

---

## Week 4 Integration Tasks

### 1. **n8n ↔ Jira Webhooks**

**Workflow:** Jira Event → n8n → Process → External System

**Setup needed:**
1. Create n8n workflow for Jira webhooks
2. Register webhook in Jira pointing to n8n
3. Test issue create/update events

**n8n nodes:**
- Webhook (receiver)
- Jira node (query/update)
- Switch/conditions
- Various output nodes

---

### 2. **Slack Integration**

**Workflow:** Jira Issue Events → Slack Channel

**Events to track:**
- Issue created (PROD, MARK, SUPP, OPS)
- Issue updated (status changes)
- Issue moved (different statuses)
- Critical issues (Priority = Highest)

**Channels:**
- `#prod-jira` - PROD project issues
- `#mark-jira` - MARK project issues
- `#supp-jira` - SUPP project issues
- `#ops-jira` - OPS project issues
- `#jira-critical` - Critical priority issues

---

### 3. **BigBlueButton Integration**

**Workflow:** Create meeting link in issue → Store in Jira → Notify Slack

**Fields needed:**
- BBB Meeting URL (link to meeting)
- Meeting Status (not started, in progress, completed)
- Recording URL (when available)

**Setup:**
1. Create n8n workflow to generate BBB meeting links
2. Store link in custom Jira field
3. Post notification to Slack with link

---

### 4. **Email Integration**

**Workflow:** Incoming email → Parse → Create Jira issue

**Supported:**
- Create SUPP ticket from customer email
- Create MARK lead from sales inquiry
- Create PROD bug report from user feedback

**Email rules:**
- `support@ai-impress.com` → Create SUPP issue
- `sales@ai-impress.com` → Create MARK issue
- `bugs@ai-impress.com` → Create PROD issue

---

## API Endpoints & Credentials Needed

### Jira Cloud
- ✅ Already configured
- URL: `https://ai-impress.atlassian.net`
- Auth: Basic (email + token)

### n8n
- URL: `https://n8n.ai-impress.com` (behind Authentik)
- Auth: API key (generate in n8n settings)
- Webhook URL: `https://n8n.ai-impress.com/webhook/jira`

### Slack
- Bot token: `xoxb-...` (from workspace settings)
- Webhook URL: Can use n8n to send to Slack API
- Channels: Already created (or create new)

### BigBlueButton
- ✅ Already deployed
- API URL: `https://bbb.ai-impress.com`
- Secret key: In docker-compose.yml
- Admin URL: Available

### Email
- IMAP/SMTP: `mail.ai-impress.com` (or external)
- Credentials: In Vault or env file
- Mailboxes: support@, sales@, bugs@

---

## Step-by-Step Implementation

### Phase 1: n8n Webhooks
1. Get n8n API key
2. Create Jira event handler workflow in n8n
3. Configure Jira webhook → n8n webhook

### Phase 2: Slack Integration
1. Create Slack bot with permissions
2. Create n8n workflow: Parse Jira event → Format → Send to Slack
3. Test with sample issues

### Phase 3: BigBlueButton
1. Get BBB API credentials
2. Create n8n workflow: Generate meeting → Store in Jira → Notify
3. Test meeting creation

### Phase 4: Email Integration
1. Configure email server access
2. Create n8n workflows for email parsing
3. Create n8n workflows: Parse email → Create Jira issue
4. Test incoming emails

---

## Files to Create

- `scripts/11-n8n-jira-webhooks.sh` - Register Jira webhooks in n8n
- `scripts/12-slack-integration.sh` - Slack bot setup
- `scripts/13-bbb-integration.sh` - BigBlueButton integration
- `scripts/14-email-integration.sh` - Email to Jira automation

---

## Estimated Work

- n8n webhooks: 30 min setup + 15 min testing
- Slack integration: 20 min
- BigBlueButton: 25 min
- Email integration: 30 min
- **Total: ~2 hours**

---

## Success Criteria

✅ Jira events appear in Slack within 5 seconds
✅ BBB meeting links created and stored in issues
✅ Email replies create issues automatically
✅ All 4 integration channels working
✅ No API rate limit issues
✅ All workflows handle errors gracefully

---

Next: Start with Phase 1 - n8n Webhooks

