본문으로 건너뛰기
Skillpedia
API 및 서버 (백엔드)8.1k · #12592

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가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/webiny/webiny-js/blob/next/skills/user-skills/api/websocket-notifications/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

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 action string; put the payload in data.
  • 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's processData sends a message per processed entry so the Admin can toast progress live.
자주 묻는 질문

어떤 Webiny 버전이 필요한가요?

웹소켓 알림은 Webiny 6.5.0 이상이 필요하다고 스킬이 설명합니다.

메시지 전송이 실패하면 어떻게 되나요?

웹소켓 실패는 실제 작업을 실패시키지 않으므로, 오류를 기록하고 무시한다고 스킬이 설명합니다.

누가 메시지를 받나요?

작업을 시작한 사용자이며, 신원 컨텍스트를 통해 찾습니다.

상세 정보

작성자의 원본 설명

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.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬