webiny-websocket-notifications
できること
このスキルは、サーバーが進行中の作業について管理画面のユーザーに知らせる必要があるとき、AIを導きます。Webinyの管理画面でライブの更新がほしい開発者向けです。
使う場面
- ✓バックグラウンドのタスクが、それを開始したユーザーに進捗を示す必要があるとき。
- ✓サーバーの変更の後に、管理画面が自動で更新されるべきとき。
- ✓メッセージが管理アプリの通知として表示されるべきとき。
スキルのリンク
https://github.com/webiny/webiny-js/blob/next/skills/user-skills/api/websocket-notifications/SKILL.mdコピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。
使い方
いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。
貼り付け用メッセージ
Claude Code、Codex、Cursorの場合:プロジェクトのフォルダで実行するとスキルがインストールされます。
SKILL.mdをダウンロードして、エージェントのスキル用フォルダに入れてください。
AIへの頼み方の例
“一括割引のジョブが各製品について終わったら、管理画面に通知を表示してください。”
毎週5つの新しいスキル。1分で読めます。
仕組み
サーバー側のコードは、作業を起動したユーザーにメッセージを送りますが、メッセージの失敗が実際の処理を壊さないようにします。管理アプリでは、ハンドラーがメッセージをそのアクションで絞り込み、通知を表示するなどの反応をします。
技術的な内容(元のSKILL.md)
作者による元のテキスト(英語)をGitHubからそのまま表示しています。
Websocket notifications (API → Admin)
TL;DR
On the API, inject WebsocketsSendToIdentityUseCase (webiny/api) + IdentityContext
(webiny/api/security) and call sendToIdentity.execute({ id }, { action, data }). On the
Admin, implement a WebsocketEventHandler (webiny/admin/websockets) that filters on
action and reacts (e.g. toast via Notifications from webiny/admin), registered with
createFeature + RegisterFeature.
API — emit
import { WebsocketsSendToIdentityUseCase } from "webiny/api";
import { IdentityContext } from "webiny/api/security";
class MyTaskOrHook {
constructor(
private identityContext: IdentityContext.Interface,
private sendToIdentity: WebsocketsSendToIdentityUseCase.Interface
) {}
async notify(entry) {
// Best-effort: a websocket failure must never fail the real work.
try {
const identity = this.identityContext.getIdentity();
if (identity) {
await this.sendToIdentity.execute(
{ id: identity.id },
{
action: "cms.product.discountApplied",
data: { id: entry.entryId, price: entry.values.price }
}
);
}
} catch (ex) {
// log & swallow
}
}
}
// dependencies: [IdentityContext, WebsocketsSendToIdentityUseCase]
- Send to the user who triggered the work — get them from
IdentityContext. In a background task/bulk action, the triggering identity is available. - Use a namespaced
actionstring; put the payload indata. - Sender data type:
{ action?: string; data?: T; error?: {...} }.
Admin — listen
import { WebsocketEventHandler } from "webiny/admin/websockets";
import { Notifications } from "webiny/admin";
const ACTION = "cms.product.discountApplied";
class MyHandlerImpl implements WebsocketEventHandler.Interface {
constructor(private notifications: Notifications.Interface) {}
async handle(event: WebsocketEventHandler.Event): Promise<void> {
const payload = event.payload as { action?: string; data?: { id: string; price: number } };
if (payload.action !== ACTION || !payload.data) {
return; // every handler sees every message — filter by action
}
this.notifications.success({
title: "Discount applied",
description: `New price ${payload.data.price}.`
});
}
}
export const MyHandler = WebsocketEventHandler.createImplementation({
implementation: MyHandlerImpl,
dependencies: [Notifications]
});
Read the message off event.payload — event.payload.action and event.payload.data
(the exact { action, data } object the API sent).
Admin — register
Register the handler in a feature and render it from your Admin.Extension:
import { createFeature, RegisterFeature } from "webiny/admin";
import { MyHandler } from "./MyHandler.js";
const MyFeature = createFeature({
name: "MyExtension/Notifications",
register(container) {
container.register(MyHandler);
}
});
export default () => <RegisterFeature feature={MyFeature} />;
The websockets runner resolves every registered WebsocketEventHandler and calls handle
for each incoming message — hence the action filter in each handler.
Related
webiny-cms-bulk-actions— the typical emitter: a bulk action'sprocessDatasends a message per processed entry so the Admin can toast progress live.
よくある質問
必要なWebinyのバージョンは?
スキルは、WebSocketの通知にはWebiny 6.5.0以降が必要だと述べています。
メッセージの送信に失敗したらどうなりますか?
スキルによると、WebSocketの失敗が実際の作業を失敗させることは決してないため、エラーは記録されて無視されます。
メッセージは誰が受け取りますか?
作業を起動したユーザーで、アイデンティティのコンテキストを通じて見つけられます。
詳細
作者による元の説明
Sending real-time notifications from the API to the Admin app over websockets, and reacting to them on the client. Use this skill when the developer wants to push a message to the user who triggered some server-side work (e.g. per-entry progress from a background task/bulk action) and show a toast, update a cache, or refresh UI in response. Requires Webiny 6.5.0 or newer.
repo: webiny/webiny-js
人気
- GitHubのスター
- 8.1k
- ランキング
- #12592
- ライセンス
- —
- 更新日
- 2026/11/2
コメント
- …
このリポジトリの他のスキル
prd-to-plan
8.1k製品要件書を、それぞれ端から端まで成立する小さなスライスの段階的な計画に変え、Markdownファイルとして保存するよう、エージェントを支援します。
webiny-admin-architect
8.1kビジネスロジックの層とプレゼンターのパターンを使い、Webinyプラットフォームの管理画面を作る方法をエージェントに教えます。
webiny-admin-permissions
8.1k自動生成される権限フォームや、表示・非表示のチェックを含め、Webinyの管理画面に権限の制御を追加するよう、エージェントに教えます。
webiny-form-model
8.1kビルダーで宣言的にフィールドを定義し、レイアウト、検証、条件付きのルールを使って、Webinyのフォームを作るよう、エージェントに教えます。
似ているスキル
api-connector-builder
280kエージェントが既存のパターンに従って、新しいAPI連携を構築します。新しい方式を作らずに、もう一つ連携を追加したいときに使います。
api-design
280kエージェントがベストプラクティスに沿ってREST APIを設計できるようにします。APIの通信方法、エラーの表示方法、データの整理方法を決めるのに役立ちます。
backend-patterns
280kエージェントのサーバーサイドのアーキテクチャパターンとデータベースの最適化を支援します。サーバー上で動くコードを作成またはレビューするときに役立ちます。