From 6208f7da362624b76dd6cbd1ab134edde2e54d44 Mon Sep 17 00:00:00 2001 From: Justin Massa Date: Sun, 11 Jan 2026 21:20:00 -0600 Subject: [PATCH] feat(googlechat): improve startup script with URL change detection - Detect when ngrok URL changes and prompt user to update Google Chat - Save URL to ~/.clawdbot-googlechat-url for comparison - Add clear instructions when URL update is needed - Skip update prompt when URL hasn't changed Co-Authored-By: Claude Opus 4.5 --- start-googlechat.sh | 55 +++++++++++++++++++++++++++++++++------------ 1 file changed, 41 insertions(+), 14 deletions(-) diff --git a/start-googlechat.sh b/start-googlechat.sh index ed3c52cfc..eef1529f1 100755 --- a/start-googlechat.sh +++ b/start-googlechat.sh @@ -4,7 +4,10 @@ cd "$(dirname "$0")" -echo "Starting Clawdbot Google Chat..." +CONFIG_FILE="$HOME/.clawdbot-googlechat-url" + +echo "" +echo "🦞 Starting Clawdbot Google Chat..." echo "" # Kill any existing processes @@ -18,39 +21,63 @@ ngrok http 18792 > /tmp/ngrok.log 2>&1 & sleep 4 # Get the ngrok URL -NGROK_URL=$(curl -s http://localhost:4040/api/tunnels | grep -o '"public_url":"https://[^"]*"' | head -1 | cut -d'"' -f4) +NGROK_URL=$(curl -s http://localhost:4040/api/tunnels 2>/dev/null | grep -o '"public_url":"https://[^"]*"' | head -1 | cut -d'"' -f4) if [ -z "$NGROK_URL" ]; then - echo " ERROR: ngrok failed to start. Check your internet connection." + echo " ❌ ERROR: ngrok failed to start. Check your internet connection." exit 1 fi -echo " ngrok URL: $NGROK_URL" -echo "" +WEBHOOK_URL="${NGROK_URL}/webhook/googlechat" +echo " ✓ Tunnel active" + +# Check if URL changed +LAST_URL=$(cat "$CONFIG_FILE" 2>/dev/null) + +if [ "$NGROK_URL" != "$LAST_URL" ]; then + echo "" + echo "==========================================" + echo "⚠️ NGROK URL CHANGED!" + echo "==========================================" + echo "" + echo "New webhook URL:" + echo "$WEBHOOK_URL" + echo "" + echo "👉 UPDATE GOOGLE CHAT NOW:" + echo " 1. Go to: https://console.cloud.google.com/apis/api/chat.googleapis.com/hangouts-chat" + echo " 2. Click Clawdbot" + echo " 3. Change HTTP endpoint URL to the new URL above" + echo " 4. Save" + echo "" + read -p "Press ENTER after you've updated Google Chat..." + + # Save the new URL + echo "$NGROK_URL" > "$CONFIG_FILE" +else + echo " ✓ Same URL as before - no Google Chat update needed!" +fi # Start webhook server +echo "" echo "2. Starting webhook server..." npx tsx src/googlechat/run-webhook.ts > /tmp/googlechat-webhook.log 2>&1 & sleep 3 # Verify webhook is running if lsof -i :18792 > /dev/null 2>&1; then - echo " Webhook running on port 18792" + echo " ✓ Webhook running" else - echo " ERROR: Webhook failed to start" + echo " ❌ ERROR: Webhook failed to start" exit 1 fi echo "" echo "==========================================" -echo "Clawdbot Google Chat is READY!" +echo "✅ Clawdbot Google Chat is READY!" echo "==========================================" echo "" -echo "Webhook URL: ${NGROK_URL}/webhook/googlechat" +echo "Webhook URL: $WEBHOOK_URL" echo "" -echo "NOTE: If the ngrok URL changed, update it in Google Chat:" -echo " https://console.cloud.google.com/apis/api/chat.googleapis.com/hangouts-chat" +echo "Logs: tail -f /tmp/googlechat-webhook.log" +echo "Stop: pkill -f ngrok && pkill -f run-webhook" echo "" -echo "Logs: tail -f /tmp/googlechat-webhook.log" -echo "" -echo "To stop: pkill -f ngrok && pkill -f run-webhook"