# Standard Foxli Workflows for AI Agents

This guide documents the recommended multi-step workflows when using the Foxli MCP server.

---

## 1. Weekly Content Plan Workflow (`weekly_content_plan`)

When the user asks to plan a week of social content (e.g., *"Plan next week's posts for Cafe Bloom on Instagram and LinkedIn"*):

1. **Discover Context**:
   - Call `list_workspaces` to identify target workspace ID and account role.
   - Call `list_channels` to find the channel IDs for the platforms requested by the user.
   - Call `get_platform_rules` to confirm current limits for the target channels.

2. **Generate Calendar & Drafts**:
   - Devise 3–5 post concepts distributed across the week (e.g. Monday announcement, Wednesday educational/product tip, Friday community spotlight).
   - Write copy tailored to each network's tone and limits (e.g. concise on X, story-driven on LinkedIn, visual hook on Instagram).
   - If first comment is requested, prepare comment text for Instagram/LinkedIn.

3. **Save as Drafts First**:
   - For each post, call `create_post` with `mode: "draft"`:
     ```json
     {
       "workspace_id": "ws_123",
       "channel_ids": ["ch_ig_01", "ch_li_02"],
       "content": "Exciting news at Cafe Bloom! Fresh brews starting Monday.",
       "mode": "draft"
     }
     ```

4. **Present to User**:
   - Show the generated drafts, post IDs, copy, and proposed schedule dates/times in a clean table or markdown list.
   - Ask the user which drafts to schedule or modify.

---

## 2. Scheduling in Local Time (IST Conversion)

Users often request posting at a specific local time, such as *"Schedule for tomorrow at 10:00 am"*. In India, the standard business timezone is **Indian Standard Time (IST, UTC+05:30)**.

Foxli's backend strictly requires ISO-8601 UTC strings (`YYYY-MM-DDTHH:mm:ssZ`).

### Conversion Formula
$$\text{UTC Time} = \text{IST Time} - 5\text{ hours } 30\text{ minutes}$$

### Reference Mapping Table
| User Requests (IST) | Sent to Foxli (`scheduled_at` in UTC) |
|---|---|
| 09:00 AM IST | `03:30:00Z` |
| 10:00 AM IST | `04:30:00Z` |
| 12:00 PM (Noon) IST | `06:30:00Z` |
| 02:30 PM IST | `09:00:00Z` |
| 05:00 PM IST | `11:30:00Z` |
| 07:00 PM IST | `13:30:00Z` |
| 09:00 PM IST | `15:30:00Z` |

### Scheduling Call
```json
{
  "post_id": "post_xyz",
  "workspace_id": "ws_123",
  "scheduled_at": "2026-11-08T04:30:00Z"
}
```
Always verify that `scheduled_at` is at least 2 minutes in the future from the current UTC moment.

---

## 3. Team & Client Approval Flow

In collaborative agencies or enterprise workspaces, team members or clients may have designated approval workflows:

1. **Verify if Approval is Required**:
   - If user is on a Team plan or operating within a client workspace, ask if the content should be routed for review.
2. **Submit Draft for Review**:
   - Instead of scheduling directly, call `submit_for_approval`:
     ```json
     {
       "post_id": "post_xyz",
       "workspace_id": "ws_123",
       "note": "Prepared weekly promotional copy for client review."
     }
     ```
3. **Notify User**:
   - State clearly: *"Draft `post_xyz` has been submitted for approval. Workspace managers or clients will be notified in the Foxli web application."*
   - Note: AI agents cannot approve or reject posts via MCP; approvals must be signed off by humans in the Foxli app.

---

## 4. Live Actions Safeguard (`publish_post_now` and `delete_post`)

Publishing immediately or deleting posts cannot be undone. Always follow this 3-step safeguard:

1. **Step 1: Inquire & Summarize**:
   - Do NOT call the tool immediately.
   - Respond in chat with a clear confirmation prompt:
     > *"You asked to publish post `post_8f2k` immediately to Instagram (@cafe_bloom) and LinkedIn. Once published, this cannot be recalled. Do you confirm?"*

2. **Step 2: Await User Affirmation**:
   - Wait for the user to explicitly say "Yes", "Confirm", "Go ahead", or similar.

3. **Step 3: Execute with Confirmation**:
   - Only after receiving user confirmation, call the tool with `"confirm": true`:
     ```json
     {
       "post_id": "post_8f2k",
       "workspace_id": "ws_123",
       "confirm": true
     }
     ```
   - If `confirm` is omitted or `false`, the server rejects the request with an error.

---

## 5. Analytics & KPI Reporting Workflow

When the user asks for performance insights (e.g. *"How did my Diwali posts perform?"*):

1. **Identify Date Range & Channels**:
   - Determine `start_date` and `end_date` (format: `YYYY-MM-DD`).
   - Determine if the query is workspace-wide or for a specific `channel_id`.

2. **Fetch Metrics**:
   - Call `get_analytics_overview`:
     ```json
     {
       "workspace_id": "ws_123",
       "start_date": "2026-10-25",
       "end_date": "2026-11-05"
     }
     ```

3. **Present Authentic Findings**:
   - Report the actual numbers returned:
     - Impressions and Reach
     - Total Engagements & Engagement Rate
     - Net Follower Change
     - Top performing posts by engagement
   - Never extrapolate missing data or invent performance figures.
