40 lines
1.2 KiB
Bash
Executable File
40 lines
1.2 KiB
Bash
Executable File
#!/bin/bash
|
|
# Daily AI Newsletter Digest - Enhanced with LLM Summarization
|
|
# Creates properly formatted digests with AI-powered summarization
|
|
|
|
SCRIPT_DIR="/home/openclaw/.openclaw/workspace/skills/imap-smtp-email"
|
|
CHECK_SCRIPT="$SCRIPT_DIR/scripts/check-anthonymau-email.js"
|
|
DIGEST_DIR="/home/openclaw/.openclaw/workspace/automations/ai-newsletter-digest"
|
|
|
|
echo "🤖 Daily AI Newsletter Digest (Enhanced)" >&2
|
|
echo "$(date)" >&2
|
|
|
|
cd "$SCRIPT_DIR"
|
|
|
|
echo "🔍 Checking for AI newsletters..." >&2
|
|
|
|
RESULT=$(NODE_TLS_REJECT_UNAUTHORIZED=0 timeout 60 node "$CHECK_SCRIPT" 2>&1)
|
|
|
|
AI_COUNT=$(echo "$RESULT" | grep "^AI_COUNT:" | cut -d: -f2)
|
|
|
|
if [ -z "$AI_COUNT" ] || [ "$AI_COUNT" = "0" ]; then
|
|
echo "No AI newsletters found" >&2
|
|
echo "🤖 No AI newsletters today. Check back tomorrow!"
|
|
exit 0
|
|
fi
|
|
|
|
echo "Found $AI_COUNT newsletters" >&2
|
|
|
|
# Write result to temp file for Python parsing
|
|
TMPFILE=$(mktemp)
|
|
echo "$RESULT" > "$TMPFILE"
|
|
|
|
# Parse AI_EMAIL / AI_CONTENT pairs with improved content extraction
|
|
PARSED=$(python3 "$DIGEST_DIR/parse-emails.py" "$TMPFILE")
|
|
|
|
echo "🧠 Generating LLM-powered summary..." >&2
|
|
|
|
# Use LLM to summarize (or fallback to basic formatting)
|
|
echo "$PARSED" | python3 "$DIGEST_DIR/summarize.py"
|
|
|
|
rm -f "$TMPFILE" |