Command Palette

Search for a command to run...

Назад к скиллам
скилл № 44328

google-chat-cards-v2

Implement Google Chat Cards v2 format for rich alert notifications. This skill should be used when migrating from plain text messages to Cards v2 format…

БесплатноБез исполняемых скриптов
danchamorroот danchamorro★ 18 звёзд на GitHub

Установить google-chat-cards-v2 в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Об этом скилле

Google Chat Cards v2 Implementation

This skill provides patterns and guidance for implementing Google Chat Cards v2 rich message format in Python services.

When to Use

  • Migrating existing plain text Google Chat alerts to Cards v2 format
  • Adding new alert/notification functionality with rich formatting
  • Implementing error alerting systems with structured card layouts

Cards v2 Structure

Cards v2 uses a nested structure with header, sections, and widgets:

{
  "cardsV2": [{
    "cardId": "unique-card-id",
    "card": {
      "header": {
        "title": "Alert Title",
        "subtitle": "service-name",
        "imageUrl": "https://icon-url.svg",
        "imageType": "CIRCLE"
      },
      "sections": [
        {
          "header": "Section Header (optional)",
          "widgets": [...]
        }
      ]
    }
  }]
}

Implementation Pattern

Step 1: Add Module-Level Retry Configuration

Extract retry configuration to a module-level constant for reuse across methods:

from tenacity import retry, retry_if_exception_type, stop_after_attempt, wait_exponential
import httpx

# Shared retry configuration for network errors
_RETRY_CONFIG = retry(
    stop=stop_after_attempt(3),
    wait=wait_exponential(multiplier=1, min=2, max=10),
    retry=retry_if_exception_type((httpx.ConnectError, httpx.TimeoutException, httpx.NetworkError)),
)

Step 2: Add send_card() Method

Add a method to send Cards v2 payloads alongside existing send_message():

@_RETRY_CONFIG
def send_card(self, card_payload: dict[str, Any]) -> ChatSendMessageResponse:
    """Send a Cards v2 message to Google Chat.

    :param card_payload: The card payload dict with cardsV2 structure.
    :returns: Response containing success status.
    """
    if error := self._validate_webhook("Card"):
        return error
    if "cardsV2" not in card_payload:
        logger.error("Invalid card payload: missing 'cardsV2' key")
        return ChatSendMessageResponse(success=False, error="Invalid card payload: missing 'cardsV2' key")
    return self._send_request(card_payload)

Step 3: Define Class Constants

Use ClassVar for static mappings that define card content:

from typing import ClassVar

class AlerterClass:
    SERVICE_NAME: ClassVar[str] = "my-service-name"

    CATEGORY_TITLE_MAP: ClassVar[dict[ErrorCategory, str]] = {
        ErrorCategory.CONFIG_ERROR: "Configuration Error",
        ErrorCategory.SYSTEM_ERROR: "System Error",
        # ... add your categories
    }

    # Google Material Symbols icons from Google Fonts CDN
    # Source: https://fonts.google.com/icons
    SEVERITY_ICON_URLS: ClassVar[dict[SeverityLevel, str]] = {
        SeverityLevel.CRITICAL: "https://fonts.gstatic.com/s/i/short-term/release/googlesymbols/error/default/48px.svg",
        SeverityLevel.HIGH: "https://fonts.gstatic.com/s/i/short-term/release/googlesymbols/warning/default/48px.svg",
        SeverityLevel.MEDIUM: "https://fonts.gstatic.com/s/i/short-term/release/googlesymbols/info/default/48px.svg",
        SeverityLevel.LOW: "https://fonts.gstatic.com/s/i/short-term/release/googlesymbols/check_circle/default/48px.svg",
    }

Step 4: Build Card Payload with Helper Methods

Break card building into focused helper methods:

def _build_card_payload(self, payload: ErrorAlertPayload) -> dict[str, Any]:
    """Build Cards v2 payload for Google Chat webhook."""
    card_id = f"alert-{payload.job_id}-{payload.timestamp.strftime('%Y%m%d%H%M%S')}"

    return {
        "cardsV2": [{
            "cardId": card_id,
            "card": {
                "header": self._build_card_header(payload),
                "sections": [
                    self._build_job_info_section(payload),
                    self._build_error_details_section(payload),
                    self._build_error_message_section(payload),
                ],
            },
        }]
    }

def _build_card_header(self, payload: ErrorAlertPayload) -> dict[str, Any]:
    """Build the card header section."""
    return {
        "title": f"Alert: {self.CATEGORY_TITLE_MAP.get(payload.error_category, 'Error')}",
        "subtitle": self.SERVICE_NAME,
        "imageUrl": self.SEVERITY_ICON_URLS.get(payload.severity),
        "imageType": "CIRCLE",
    }

Widget Types

Decorated Text (with icons)

Use for key-value pairs with optional icons:

{
    "decoratedText": {
        "startIcon": {"knownIcon": "BOOKMARK"},  # Optional icon
        "topLabel": "Job ID",
        "text": "12345",
    }
}

Available knownIcon values: BOOKMARK, DESCRIPTION, PERSON, CLOCK, EMAIL, STAR, etc.

Decorated Text (label only)

For simpler key-value display:

{"decoratedText": {"topLabel": "Stage", "text": "validation"}}

Text Paragraph

For longer text content:

{"textParagraph": {"text": "Error message or description here"}}

Section Structure

Sections can have an opti

Полный SKILL.md на GitHub

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

  • references/bridge_tap_implementation.md

FAQ

Что делает скилл google-chat-cards-v2?

Implement Google Chat Cards v2 format for rich alert notifications. This skill should be used when migrating from plain text messages to Cards v2 format, adding visual alerts to Google Chat webhooks, or building card-based notification systems.

Как установить скилл google-chat-cards-v2?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл google-chat-cards-v2 запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить google-chat-cards-v2 с