#!/usr/bin/env bash
# Morning scoreboard
# Yesterday on one screen: calls, SMS, email and agent productivity. Pipe it into Slack on a cron and the team starts the day with the same numbers.
#
# Category : Reporting
# Safety   : read only
# Uses     : reports run
# Returns  : A compact digest of yesterday across every channel.
#
# Requires the SendSquared CLI and jq:
#   curl -fsSL https://cli.sendsquared.com/install.sh | bash
#   sendsquared auth login
#
# Free to use and adapt. https://sendsquared.com/cli/scripts/#morning-scoreboard

# Yesterday across every channel, in one block.
set -euo pipefail
DAY=${1:-$(date -u -v-1d +%F 2>/dev/null || date -u -d "-1 day" +%F)}

echo "SendSquared report for $DAY"
echo

for R in call_volume_stats sms_volume_stats email_campaign_overview; do
  echo "## $R"
  sendsquared reports run "$R" --from "$DAY" --to "$DAY" -o md 2>/dev/null | sed -n '1,14p' || echo "  (unavailable)"
  echo
done
