{"id":"add-gchat","name":"add-gchat","summary":"Chat SDKを通じてGoogleチャットのチャンネル統合を追加してください。","body":"# Add Google Chat Channel\n\nAdds Google Chat support via the Chat SDK bridge. NanoClaw doesn't ship channels\nin trunk — this skill copies the Google Chat adapter in from the `channels`\nbranch.\n\nThe mechanical steps under **Apply** carry `nc:` directive fences: an agent\nreads the prose and applies them, and a parser can apply them deterministically\nfrom the same document. Every directive is idempotent, so the whole skill is\nsafe to re-run; anything a parser can't apply falls back to the prose beside it.\n\n## Apply\n\n### 1. Copy the adapter and its registration test\n\nFetch the `channels` branch and copy the Google Chat adapter and its\nregistration test into `src/channels/` (overwrite — the branch is canonical):\n\n```nc:copy from-branch:channels\nsrc/channels/gchat.ts\nsrc/channels/gchat-registration.test.ts\n```\n\n### 2. Register the adapter\n\nAppend the self-registration import to the channel barrel (skipped if the line\nis already present). This one line is the skill's only reach-in into core:\n\n```nc:append to:src/channels/index.ts\nimport './gchat.js';\n```\n\n### 3. Install the adapter package\n\nPinned to an exact version — the supply-chain policy rejects ranges and `latest`:\n\n```nc:dep\n@chat-adapter/gchat@4.29.0\n```\n\n### 4. Build and validate\n\nBuild first: it guards the typed `createChatSdkBridge(...)` core call and proves\nthe dependency is installed. Then run the one integration test.\n\n```nc:run effect:build\npnpm run build\n```\n```nc:run effect:test\npnpm exec vitest run src/channels/gchat-registration.test.ts\n```\n\n`gchat-registration.test.ts` imports the real channel barrel and asserts the\nregistry contains `gchat`. It goes red if the import line is deleted or drifts,\nif the barrel fails to evaluate, or if `@chat-adapter/gchat` isn't installed (the\nimport throws) — so it also covers the dependency from step 3. End-to-end\ndelivery against a real Google Chat space is verified manually once the service\nruns — see Credentials and Next Steps.\n\n## Credentials\n\nGoogle Cloud setup is human and interactive — these steps are prose, not\ndirectives (no parser can click through the Google Cloud Console). A recipe\nrebuild produces a compiling, registered adapter that cannot receive a message\nuntil they're done.\n\n> 1. Go to [Google Cloud Console](https://console.cloud.google.com)\n> 2. Create or select a project\n> 3. Enable the **Google Chat API**\n> 4. Go to **Google Chat API** > **Configuration**:\n>    - App name and description\n>    - Connection settings: select **HTTP endpoint URL** and set to `https://your-domain/webhook/gchat`\n> 5. Create a **Service Account**:\n>    - Go to **IAM & Admin** > **Service Accounts** > **Create Service Account**\n>    - Grant the Chat Bot role\n>    - Create a JSON key and download it\n\n### Store the credentials\n\nCapture the service account JSON, then write it. `prompt` only *asks* and binds\nthe answer to a name; a separate directive consumes it — so the same prompt\ncould feed `ncl` or the OneCLI vault instead of `.env` by swapping only the\nconsumer. Here it goes to `.env` (set-if-absent — a value you've already filled\nin is never overwritten) as a single-line string:\n\n```nc:prompt gchat_credentials secret\nPaste the service account JSON as a single line — the key file you downloaded, e.g. `{\"type\":\"service_account\",\"project_id\":\"...\",\"private_key\":\"...\",\"client_email\":\"...\"}`.\n```\n```nc:env-set\nGCHAT_CREDENTIALS={{gchat_credentials}}\n```\n### Webhook server\n\nThe Chat SDK bridge automatically starts a shared webhook server on port 3000\n(`WEBHOOK_PORT` to change it), handling `/webhook/gchat`. This port must be\npublicly reachable for Google Chat to deliver events — it's the HTTP endpoint\nURL you set in the Connection settings above. Running locally, expose it with\nngrok (`ngrok http 3000`), a Cloudflare Tunnel, or a reverse proxy on a VPS.\n\n## Next Steps\n\nIf you're in the middle of `/setup`, return to the setup flow now. Otherwise run\n`/manage-channels` to wire this channel to an agent group.\n\n## Channel Info\n\n- **type**: `gchat`\n- **terminology**: Google Chat has \"spaces.\" A space can be a group conversation or a direct message with the bot.\n- **how-to-find-id**: Open the space in Google Chat, look at the URL — the space ID is the segment after `/space/` (e.g. `spaces/AAAA...`). Or use the Google Chat API to list spaces.\n- **supports-threads**: yes\n- **typical-use**: Interactive chat — team spaces or direct messages\n- **default-isolation**: Same agent group for spaces where you're the primary user. Separate agent group for spaces with different teams or sensitive contexts.\n\n## Troubleshooting\n\n**The adapter starts, then errors about credentials.** `GCHAT_CREDENTIALS` must be the *entire* service account JSON collapsed to one line — inspect `.env` and confirm it still contains `\"type\":\"service_account\"`, `\"private_key\"`, and `\"client_email\"`. A truncated paste (shells often mangle the multi-line private key) is the usual cause; download a fresh JSON key under **IAM & Admin → Service Accounts → Keys** and re-paste it as a single line.\n\n**Messages sent in the space never reach the agent.** Google Chat delivers only to the HTTP endpoint URL set under **Google Chat API → Configuration**, and that URL must be publicly reachable at `/webhook/gchat` (shared webhook server, port 3000). Tunnel hostnames (ngrok free tier) change on restart — make sure the Configuration URL matches the tunnel that's actually up.\n\n**The app doesn't appear when adding it to a space.** Check the Chat API Configuration page: the app status must be live and its visibility must include your domain or user, and you must be adding it from the same Google Workspace the Cloud project belongs to.\n\n**Everything configured but still silent.** Run `pnpm exec vitest run src/channels/gchat-registration.test.ts` — red means the barrel import or the `@chat-adapter/gchat` install drifted, so re-run the Apply steps. If green, restart the service so it picks up the adapter and `.env`, then watch `logs/nanoclaw.log` for the inbound webhook hit.","author":"@nanocoai","ownerProfile":null,"authorContacts":null,"sourceUrl":"https://github.com/nanocoai/nanoclaw/tree/main/.claude/skills/add-gchat","license":"MIT","category":"writing","lang":"en","tokens":1444,"stars":0,"calls30d":2,"claimed":false,"visibility":"public","origin":"crawler","version":"0.1.0","createdAt":"2026-08-22","updatedAt":"2026-08-22","files":[{"path":"apply-fixtures.json","size":284,"sha256":"1ebacbff9de643571a83481a2185fa5969db489bfe10093288f63cc0592d40c5"},{"path":"REMOVE.md","size":704,"sha256":"4fd6aa315600d917364c98ec3dec38f59c2c84873ce865b14d7a4b635e650762"}],"requires":{"mcp":[],"tools":[]},"safety":{"flags":[],"scannedAt":"2026-08-22","hasScripts":false,"networkEndpoints":["console.cloud.google.com"]}}