#!/bin/bash

# Daily Marketing Content Generation
# Triggers the marketing-content-creator subagent via OpenClaw Gateway API

LOG_FILE="/Users/claw/.openclaw/workspace/agents/marketing-content/cron.log"
DATE=$(date +%Y-%m-%d)

echo "[$(date)] Starting daily marketing content generation" >> "$LOG_FILE"

# Run via openclaw agent command which routes through the gateway
# Using the agent turn execution with a message payload
TASK_MSG="You are the Marketing Content Creator for HoaLedgerIQ. Today is $DATE. Run your full daily workflow: 1) Research hoaledgeriq.com product features, 2) Search web for HOA/condo financial trends, 3) Create dated content: twitter thread, blog outline, linkedin post, image concepts. Never post anything, only create drafts. Save all files dated with $DATE."

# Use a dedicated session for marketing-content to avoid locking the main session MARKETING_SESSION_ID="3095ddeb-c39c-4740-b01d-599feb0213a4" openclaw agent --session-id "$MARKETING_SESSION_ID" -m "$TASK_MSG" --thinking low >> "$LOG_FILE" 2>&1

EXIT_CODE=$?
echo "[$(date)] Completed with exit code: $EXIT_CODE" >> "$LOG_FILE"
