Skip to content

jezweb/claude-skills / plugins/integrations/skills/google-chat-messages

google-chat-messages

Verified

Send Google Chat messages via incoming webhooks — text, rich cards (cardsV2), threaded replies. TypeScript types, card builder utility, widget reference inline. Use whenever the user wants to post to Google Chat from a script, build a chatbot reply, send a notification card, build a Google Chat webhook integration, or troubleshoot card / threading issues.

FileKindSize
SKILL.mdskill md9.6 KB
assets/card-builder.tsscript1.5 KB
assets/types.tsscript1.5 KB
assets/webhook-sender.tsscript1.8 KB

assets/webhook-sender.ts

View on GitHub
import type { WebhookMessage } from './types';

interface SendOptions {
  /** Thread key for threading messages together */
  threadKey?: string;
  /** If true, replies to existing thread or falls back to new thread */
  replyToThread?: boolean;
}

/**
 * Send a message to Google Chat via incoming webhook.
 *
 * @param webhookUrl - The webhook URL from Google Chat space settings
 * @param message - WebhookMessage (use buildCard or buildText to create)
 * @param options - Threading options
 *
 * @example
 *   // Simple text
 *   await sendWebhook(url, { text: '*Hello* from webhook' });
 *
 *   // Card message
 *   const card = buildCard({ cardId: 'test', title: 'Test', sections: [...] });
 *   await sendWebhook(url, card);
 *
 *   // Threaded reply
 *   await sendWebhook(url, card, { threadKey: 'deploy-123', replyToThread: true });
 */
export async function sendWebhook(
  webhookUrl: string,
  message: WebhookMessage,
  options?: SendOptions
): Promise<void> {
  let url = webhookUrl;

  // Add threading parameters to URL
  if (options?.replyToThread && options?.threadKey) {
    const separator = url.includes('?') ? '&' : '?';
    url += `${separator}messageReplyOption=REPLY_MESSAGE_FALLBACK_TO_NEW_THREAD`;
  }

  // Add thread key to message body
  if (options?.threadKey) {
    message.thread = { threadKey: options.threadKey };
  }

  const response = await fetch(url, {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify(message),
  });

  if (!response.ok) {
    const body = await response.text();
    throw new Error(
      `Google Chat webhook error ${response.status}: ${body}`
    );
  }
}

/**
 * Convenience: send a text message.
 */
export async function sendText(
  webhookUrl: string,
  text: string,
  options?: SendOptions
): Promise<void> {
  await sendWebhook(webhookUrl, { text }, options);
}
receiving-code-reviewobra/superpowersUse when receiving code review feedback, before implementing suggestions, especially if feedback seems unclear or technically questionable - requires technical rigor and verification, not performative agreement or blind implementationStars: 322kUpdated Claude CodeCodexVerifiedInstall
requesting-code-reviewobra/superpowersUse when completing tasks, implementing major features, or before merging to verify work meets requirementsStars: 322kUpdated Claude CodeCodexVerifiedInstall
using-git-worktreesobra/superpowersUse when starting feature work that needs isolation from current workspace or before executing implementation plans - ensures an isolated workspace exists via native tools or git worktree fallbackStars: 322kUpdated Claude CodeCodexVerifiedInstall
verification-before-completionobra/superpowersUse when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions alwaysStars: 322kUpdated Claude CodeCodexVerifiedInstall