Automatic channel and contact synchronization
Runs the Channel Truth Agent to synchronize last_contact timestamps
Channel Truth Agent:
activities.csvpeople.csv, leads.csv, clients.csv with current dates# Full run (default)
cd $AGENTS_PATH/channel-truth
python3 channel_truth_agent.py
# Dry-run (read only, no writes)
python3 channel_truth_agent.py --dry-run
# Single contact (for debugging)
python3 channel_truth_agent.py --person-id=p-acme-001
# Without channel scanning (activities.csv only)
python3 channel_truth_agent.py --no-channels
# Check if activities.csv exists
ls -lh $CRM_PATH/activities.csv
# Check people.csv
ls -lh $CRM_PATH/contacts/people.csv
# Dry-run test
python3 channel_truth_agent.py --dry-run
# View report
ls -lt $AGENTS_PATH/reports/channel_truth_*.md | head -1
# View latest report
cat $(ls -t $AGENTS_PATH/reports/channel_truth_*.md | head -1)
# View logs
tail -20 $AGENTS_PATH/logs/channel_truth.json
Updated CSV files:
people.csv - added last_contact and last_updatedleads.csv - added last_contact_via_primaryclients.csv - added last_contact_via_primaryReport:
$AGENTS_PATH/reports/channel_truth_YYYY-MM-DD.mdBackup files:
people.csv.bak.TIMESTAMPleads.csv.bak.TIMESTAMPclients.csv.bak.TIMESTAMPTelegram notification:
If something went wrong:
# Rollback via backup
cd $CRM_PATH/contacts/
ls -lt people.csv.bak.* | head -1
cp people.csv.bak.YYYYMMDD_HHMMSS people.csv
cd ../relationships/
cp leads.csv.bak.YYYYMMDD_HHMMSS leads.csv
cp clients.csv.bak.YYYYMMDD_HHMMSS clients.csv
# Or via git
cd $PROJECT_ROOT
git log --oneline sales/crm/
git revert <commit-hash>
Agent runs automatically via launchd:
~/Library/LaunchAgents/com.yourcompany.channel-truth-agent.plist# Check status
launchctl list | grep channel-truth
# Reload
launchctl unload ~/Library/LaunchAgents/com.yourcompany.channel-truth-agent.plist
launchctl load ~/Library/LaunchAgents/com.yourcompany.channel-truth-agent.plist
# Check path
ls -l $CRM_PATH/activities.csv
# If missing - create a basic one
echo "activity_id,person_id,company_id,product_id,type,channel,direction,subject,notes,date,created_by" > activities.csv
# Check Telegram credentials
ls -l $SALES_PATH/telegram/sessions/
# Test tg-tools
cd $TG_TOOLS_PATH
python3 -c "from tg_utils.auth import get_client; import asyncio; asyncio.run(get_client())"
# Skip channel scanning
python3 channel_truth_agent.py --no-channels
log-activity - logs activities in activities.csvgit-workflow - for committing changes (if needed)telegram-send - for manually sending messages# User: "run channel truth in dry-run"
cd $AGENTS_PATH/channel-truth
python3 channel_truth_agent.py --dry-run
# View what will be changed
cat /tmp/channel-truth-output.txt
# If everything is ok - run for real
python3 channel_truth_agent.py
# View report
cat $(ls -t $AGENTS_PATH/reports/channel_truth_*.md | head -1)