feat: Add Chatwoot Agent Bot prototype and FAQ knowledge base
- Created chatwoot-agent-bot/ with Node.js webhook server - Bot detects intent (greeting, billing, technical, features, account) - Auto-responds from FAQ knowledge base or escalates to human - FAQ-KB.md: Living knowledge base that grows with customer questions - CHATWOOT-SETUP.md: Complete deployment and configuration guide - Supports Telegram notifications on escalation - Bot runs on port 3001, ready for Chatwoot webhook integration
This commit is contained in:
93
agents/morning-report/generate-report-fixed-fixed.sh
Executable file
93
agents/morning-report/generate-report-fixed-fixed.sh
Executable file
@@ -0,0 +1,93 @@
|
||||
#!/bin/bash
|
||||
# Morning Business Summary - 9 AM Daily Report
|
||||
|
||||
YESTERDAY=$(date -v-1d '+%Y-%m-%d')
|
||||
YESTERDAY_DASH=$(date -v-1d '+%Y%m%d')
|
||||
|
||||
echo "📊 MORNING BUSINESS SUMMARY"
|
||||
echo "📆 $(date '+%A, %B %d, %Y')"
|
||||
echo "📈 Prior 24 Hours Activity (since $YESTERDAY)"
|
||||
echo ""
|
||||
|
||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||
echo "🏠 SALES PROSPECTOR LEADS"
|
||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||
PROSPECTOR_LOG="/Users/claw/.openclaw/workspace/agents/sales-prospector/logs/prospector-v14-$YESTERDAY_DASH.log"
|
||||
if [ -f "$PROSPECTOR_LOG" ]; then
|
||||
LEADS_FOUND=$(grep -c "LEAD [0-9]" "$PROSPECTOR_LOG" 2>/dev/null || echo "0")
|
||||
echo "✅ Leads discovered yesterday: ${LEADS_FOUND:-0}"
|
||||
echo ""
|
||||
echo "Recent leads:"
|
||||
grep "LEAD [0-9]" "$PROSPECTOR_LOG" 2>/dev/null | tail -3 | while read line; do
|
||||
echo " → $line"
|
||||
done
|
||||
else
|
||||
TOTAL=$(cat /Users/claw/.openclaw/workspace/agents/sales-prospector/state/prospector-v14-state.json 2>/dev/null | python3 -c "import json,sys; d=json.load(sys.stdin); print(d.get('leads',0))")
|
||||
echo "✅ Total prospector leads: ${TOTAL:-0}"
|
||||
echo " (v14 complete, targeting 750)"
|
||||
fi
|
||||
echo ""
|
||||
|
||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||
echo "🤖 JAE LEAD QUALIFICATIONS"
|
||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||
JAE_LOG="/Users/claw/.openclaw/workspace/agents/junior-ae/logs/jae-v3-$YESTERDAY_DASH.log"
|
||||
if [ -f "$JAE_LOG" ]; then
|
||||
UPGRADES=$(grep -c "UPGRADE" "$JAE_LOG" 2>/dev/null || echo "0")
|
||||
DONE_LINE=$(grep "Done:" "$JAE_LOG" 2>/dev/null | tail -1)
|
||||
PROCESSED=$(echo "$DONE_LINE" | grep -o "[0-9]* processed" | head -1 | grep -o "[0-9]*")
|
||||
echo "✅ Leads elevated: ${UPGRADES:-0}"
|
||||
echo "✅ Total processed: ${PROCESSED:-0}"
|
||||
else
|
||||
STATE_FILE="/Users/claw/.openclaw/workspace/agents/junior-ae/state/jae-v3-state.json"
|
||||
if [ -f "$STATE_FILE" ]; then
|
||||
cat "$STATE_FILE" | python3 -c "
|
||||
import json,sys
|
||||
d=json.load(sys.stdin)
|
||||
print(f'Total processed: {d.get(\"processed\",0)}')
|
||||
print(f'Total upgraded: {d.get(\"upgraded\",0)}')
|
||||
print(f'Last run: {d.get(\"last_check\",\"never\")[:19]}')
|
||||
"
|
||||
fi
|
||||
fi
|
||||
echo ""
|
||||
|
||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||
echo "🌐 WEBSITE LEADS"
|
||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||
INTEGRATION_LOG="/Users/claw/.openclaw/workspace/agents/sales-lead/integration.log"
|
||||
YESTERDAY_GREP=$(date -v-1d '+%a %b %d' | sed 's/ 0//')
|
||||
WEBSITE_LEADS=$(grep -c "NEW LEAD" "$INTEGRATION_LOG" 2>/dev/null || echo "0")
|
||||
|
||||
# Get yesterday's leads count - fix double echo
|
||||
YESTERDAY_LEADS_RAW=$(grep "$YESTERDAY_GREP" "$INTEGRATION_LOG" 2>/dev/null | grep -c "NEW LEAD")
|
||||
if [ -z "$YESTERDAY_LEADS_RAW" ]; then
|
||||
YESTERDAY_LEADS_RAW=0
|
||||
fi
|
||||
|
||||
echo "✅ All-time website leads: ${WEBSITE_LEADS:-0}"
|
||||
echo "✅ Yesterday's submissions: ~${YESTERDAY_LEADS_RAW:-0}"
|
||||
|
||||
echo ""
|
||||
echo "Recent website leads:"
|
||||
grep "NEW LEAD" "$INTEGRATION_LOG" 2>/dev/null | tail -3
|
||||
|
||||
echo ""
|
||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||
echo "☕ Generated at $(date '+%I:%M %p %Z')"
|
||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||
|
||||
# Auto-send to Telegram
|
||||
MSG="📊 MORNING REPORT - $(date '+%b %d')
|
||||
|
||||
*Prospector:* $(cat /Users/claw/.openclaw/workspace/agents/sales-prospector/state/prospector-v14-state.json 2>/dev/null | python3 -c 'import json,sys; print(json.load(sys.stdin).get("leads",0))') leads
|
||||
*JAE:* $(cat /Users/claw/.openclaw/workspace/agents/junior-ae/state/jae-v3-state.json 2>/dev/null | python3 -c 'import json,sys; d=json.load(sys.stdin); print(f"{d.get(\"upgraded\",0)} upgraded")')
|
||||
*Website:* $(grep -c 'NEW LEAD' /Users/claw/.openclaw/workspace/agents/sales-lead/integration.log 2>/dev/null || echo '0') total
|
||||
|
||||
Report complete."
|
||||
|
||||
# Try OpenClaw then curl fallback
|
||||
curl -s -X POST "https://api.telegram.org/bot${BOT_TOKEN:-}/sendMessage" \
|
||||
-d "chat_id=${CHAT_ID:-}&text=${MSG}&parse_mode=Markdown" 2>/dev/null || \
|
||||
openclaw message send --text "$MSG" 2>/dev/null || \
|
||||
echo "Report ready: $(date)" >> ~/.openclaw/workspace/agents/morning-report/logs/sent.log
|
||||
99
agents/morning-report/generate-report-fixed.sh
Executable file
99
agents/morning-report/generate-report-fixed.sh
Executable file
@@ -0,0 +1,99 @@
|
||||
#!/bin/bash
|
||||
# Morning Business Summary - 9 AM Daily Report
|
||||
|
||||
YESTERDAY=$(date -v-1d '+%Y-%m-%d')
|
||||
YESTERDAY_DASH=$(date -v-1d '+%Y%m%d')
|
||||
|
||||
echo "📊 MORNING BUSINESS SUMMARY"
|
||||
echo "📆 $(date '+%A, %B %d, %Y')"
|
||||
echo "📈 Prior 24 Hours Activity (since $YESTERDAY)"
|
||||
echo ""
|
||||
|
||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||
echo "🏠 SALES PROSPECTOR LEADS"
|
||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||
PROSPECTOR_LOG="/Users/claw/.openclaw/workspace/agents/sales-prospector/logs/prospector-v14-$YESTERDAY_DASH.log"
|
||||
if [ -f "$PROSPECTOR_LOG" ]; then
|
||||
# Count LEAD entries
|
||||
LEADS_FOUND=$(grep -c "LEAD [0-9]" "$PROSPECTOR_LOG" 2>/dev/null || echo "0")
|
||||
echo "✅ Leads discovered yesterday: ${LEADS_FOUND:-0}"
|
||||
echo ""
|
||||
echo "Recent leads:"
|
||||
grep "LEAD [0-9]" "$PROSPECTOR_LOG" 2>/dev/null | tail -3 | while read line; do
|
||||
echo " → $line"
|
||||
done
|
||||
else
|
||||
# Check total from state
|
||||
TOTAL=$(cat /Users/claw/.openclaw/workspace/agents/sales-prospector/state/prospector-v14-state.json 2>/dev/null | python3 -c "import json,sys; d=json.load(sys.stdin); print(d.get('leads',0))")
|
||||
echo "✅ Total prospector leads: ${TOTAL:-0}"
|
||||
echo " (v14 complete, targeting 750)"
|
||||
fi
|
||||
echo ""
|
||||
|
||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||
echo "🤖 JAE LEAD QUALIFICATIONS"
|
||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||
JAE_LOG="/Users/claw/.openclaw/workspace/agents/junior-ae/logs/jae-v3-$YESTERDAY_DASH.log"
|
||||
if [ -f "$JAE_LOG" ]; then
|
||||
UPGRADES=$(grep -c "UPGRADE" "$JAE_LOG" 2>/dev/null || echo "0")
|
||||
DONE_LINE=$(grep "Done:" "$JAE_LOG" 2>/dev/null | tail -1)
|
||||
PROCESSED=$(echo "$DONE_LINE" | grep -o "[0-9]* processed" | head -1 | grep -o "[0-9]*")
|
||||
echo "✅ Leads elevated: ${UPGRADES:-0}"
|
||||
echo "✅ Total processed: ${PROCESSED:-0}"
|
||||
if [ "$PROCESSED" -gt 0 ] 2>/dev/null; then
|
||||
RATE=$(( UPGRADES * 100 / PROCESSED ))
|
||||
echo " Validation rate: ${RATE}%"
|
||||
fi
|
||||
else
|
||||
STATE_FILE="/Users/claw/.openclaw/workspace/agents/junior-ae/state/jae-v3-state.json"
|
||||
if [ -f "$STATE_FILE" ]; then
|
||||
cat "$STATE_FILE" | python3 -c "
|
||||
import json,sys
|
||||
d=json.load(sys.stdin)
|
||||
print(f\"Total processed: {d.get('processed',0)}\")
|
||||
print(f\"Total upgraded: {d.get('upgraded',0)}\")
|
||||
print(f\"Last run: {d.get('last_check','never')[:19]}\")
|
||||
"
|
||||
fi
|
||||
fi
|
||||
echo ""
|
||||
|
||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||
echo "🌐 WEBSITE LEADS"
|
||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||
INTEGRATION_LOG="/Users/claw/.openclaw/workspace/agents/sales-lead/integration.log"
|
||||
YESTERDAY_GREP=$(date -v-1d '+%a %b %d' | sed 's/ 0/ /')
|
||||
WEBSITE_LEADS=$(grep -c "NEW LEAD" "$INTEGRATION_LOG" 2>/dev/null || echo "0")
|
||||
YESTERDAY_LEADS_COUNT=$(grep "$YESTERDAY_GREP" "$INTEGRATION_LOG" 2>/dev/null | grep -c "NEW LEAD" 2>/dev/null); YESTERDAY_LEADS_COUNT=${YESTERDAY_LEADS_COUNT:-0}
|
||||
|
||||
echo "✅ All-time website leads: ${WEBSITE_LEADS:-0}"
|
||||
echo "✅ Yesterday's submissions: ~${YESTERDAY_LEADS_COUNT:-0}"
|
||||
|
||||
# Show last few leads
|
||||
echo ""
|
||||
echo "Recent website leads:"
|
||||
grep "NEW LEAD" "$INTEGRATION_LOG" 2>/dev/null | tail -3
|
||||
|
||||
echo ""
|
||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||
echo "☕ Generated at $(date '+%I:%M %p %Z')"
|
||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||
|
||||
# Auto-send to Telegram via OpenClaw
|
||||
send_telegram() {
|
||||
MSG=$(<<-EOF
|
||||
📊 *MORNING BUSINESS REPORT*
|
||||
$(date '+📆 %A, %B %d, %Y')
|
||||
|
||||
*Prospector:* $PROSPECTOR_LEADS leads
|
||||
*JAE:* $JAE_PROCESSED processed, $JAE_UPGRADED upgraded
|
||||
*Website:* $WEBSITE_LEADS all-time, $YESTERDAY today
|
||||
|
||||
$(if [ "${YESTERDAY_LEADS_COUNT:-0}" -gt 0 ]; then echo "✅ Active day"; else echo "⚠️ No new activity"; fi)
|
||||
EOF
|
||||
)
|
||||
# Use OpenClaw's messaging
|
||||
openclaw message send --channel telegram --target telegram:8269921691 --message "$MSG" 2>/dev/null || echo "$MSG" >&2
|
||||
}
|
||||
|
||||
send_telegram
|
||||
90
agents/morning-report/generate-report.sh
Executable file
90
agents/morning-report/generate-report.sh
Executable file
@@ -0,0 +1,90 @@
|
||||
#!/bin/bash
|
||||
# Morning Business Summary - 9 AM Daily Report
|
||||
# Generates summary of prior 24h activity
|
||||
|
||||
WORKSPACE="/Users/claw/.openclaw/workspace/agents/morning-report"
|
||||
YESTERDAY=$(date -d "yesterday" +%Y-%m-%d)
|
||||
TODAY=$(date +%Y-%m-%d)
|
||||
YESTERDAY_START="${YESTERDAY}T00:00:00"
|
||||
YESTERDAY_END="${TODAY}T00:00:00"
|
||||
|
||||
# 1. Sales Prospector Leads Found Yesterday
|
||||
echo "📊 MORNING BUSINESS SUMMARY"
|
||||
echo "📆 $(date '+%A, %B %d, %Y')"
|
||||
echo "📈 Prior 24 Hours Activity"
|
||||
echo ""
|
||||
|
||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||
echo "🏠 SALES PROSPECTOR LEADS"
|
||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||
PROSPECTOR_LOGS="/Users/claw/.openclaw/workspace/agents/sales-prospector/logs/"
|
||||
if [ -d "$PROSPECTOR_LOGS" ]; then
|
||||
# Check yesterday's logs
|
||||
YESTERDAY_LOG="${PROSPECTOR_LOGS}/prospector-*-${YESTERDAY//-/}.log"
|
||||
LEADS_FOUND=$(grep -h "LEAD [0-9]" $YESTERDAY_LOG 2>/dev/null | wc -l)
|
||||
echo "✅ Leads discovered yesterday: ${LEADS_FOUND:-0}"
|
||||
|
||||
# Show yesterday's leads
|
||||
grep -h "LEAD [0-9]" $YESTERDAY_LOG 2>/dev/null | tail -5 | while read line; do
|
||||
echo " → $line"
|
||||
done
|
||||
else
|
||||
echo "⚠️ No prospector logs found"
|
||||
fi
|
||||
echo ""
|
||||
|
||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||
echo "🤖 JAE LEAD QUALIFICATIONS"
|
||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||
JAE_LOGS="/Users/claw/.openclaw/workspace/agents/junior-ae/logs/"
|
||||
if [ -d "$JAE_LOGS" ]; then
|
||||
# Check yesterday's JAE activity
|
||||
YESTERDAY_JAE="${JAE_LOGS}/jae-*-${YESTERDAY//-/}.log"
|
||||
UPGRADES=$(grep -h "UPGRADE" $YESTERDAY_JAE 2>/dev/null | wc -l)
|
||||
PROCESSED=$(grep -h "Done:" $YESTERDAY_JAE 2>/dev/null | tail -1 | grep -o "[0-9]* processed" | grep -o "[0-9]*")
|
||||
echo "✅ Leads elevated (COLD→WARM or WARM→HOT): ${UPGRADES:-0}"
|
||||
echo "✅ Total processed: ${PROCESSED:-0}"
|
||||
echo ""
|
||||
echo " Validation rate: ~${UPGRADES} upgrades from ${PROCESSED:-0} checks"
|
||||
else
|
||||
echo "⚠️ No JAE logs found"
|
||||
fi
|
||||
echo ""
|
||||
|
||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||
echo "🌐 WEBSITE LEADS"
|
||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||
INTEGRATION_LOG="/Users/claw/.openclaw/workspace/agents/sales-lead/integration.log"
|
||||
WEBSITE_LEADS=$(grep "NEW LEAD.*$(date -d yesterday '+%Y-%m-%d')" "$INTEGRATION_LOG" 2>/dev/null | wc -l)
|
||||
|
||||
echo "✅ Website form submissions: ${WEBSITE_LEADS:-0}"
|
||||
|
||||
# Count by source
|
||||
INTEREST_FORM=$(grep "NEW LEAD" "$INTEGRATION_LOG" 2>/dev/null | grep "$(date -d yesterday '+%Y-%m-%d')" | grep -i "interest\|landing" | wc -l)
|
||||
ROI_CALC=$(grep "NEW LEAD" "$INTEGRATION_LOG" 2>/dev/null | grep "$(date -d yesterday '+%Y-%m-%d')" | grep -i "calc\|calculator" | wc -l)
|
||||
|
||||
echo " → Interest form: ${INTEREST_FORM:-0}"
|
||||
echo " → ROI calculator: ${ROI_CALC:-0}"
|
||||
echo ""
|
||||
|
||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||
echo "📊 TOTAL NEW OPPORTUNITIES"
|
||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||
TOTAL=$((LEADS_FOUND + WEBSITE_LEADS))
|
||||
echo "🎯 Total new leads in CRM: $TOTAL"
|
||||
echo ""
|
||||
|
||||
# Optional: current totals
|
||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||
echo "📈 CRM STATUS (All Time)"
|
||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||
PROSPECTOR_STATE="/Users/claw/.openclaw/workspace/agents/sales-prospector/state/prospector-v14-state.json"
|
||||
if [ -f "$PROSPECTOR_STATE" ]; then
|
||||
TOTAL_PROSPECTOR=$(cat "$PROSPECTOR_STATE" | python3 -c "import json,sys; print(json.load(sys.stdin).get('leads',0))" 2>/dev/null)
|
||||
echo " Total prospector leads: ${TOTAL_PROSPECTOR:-0}"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||
echo "☕ Generated at $(date '+%I:%M %p %Z')"
|
||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||
Reference in New Issue
Block a user