webiny-websocket-notifications
Fungsinya
Skill ini memandu AI Anda saat server perlu memberi tahu pengguna admin tentang pekerjaan yang sedang berjalan. Skill ini untuk developer yang ingin pembaruan langsung di admin Webiny.
Kapan dipakai
- βSaat tugas latar belakang harus menampilkan progres kepada pengguna yang memulainya.
- βSaat layar admin perlu menyegarkan diri secara otomatis setelah ada perubahan di server.
- βSaat pesan harus muncul sebagai notifikasi di aplikasi admin.
Link skill
https://github.com/webiny/webiny-js/blob/next/skills/user-skills/api/websocket-notifications/SKILL.mdSalin lalu tempelkan ke AI Anda (Claude, ChatGPT, atau Cursor) dan minta AI mengikuti instruksinya.
Cara pakai
Cara paling mudah: salin pesan ini dan tempelkan ke AI Anda. AI akan membaca skill dan mengikuti instruksinya.
Pesan siap tempel
Untuk Claude Code, Codex, atau Cursor: jalankan di folder proyek, lalu skill langsung terpasang.
Unduh SKILL.md lalu taruh di folder skill agen Anda.
Contoh permintaan ke AI
βTampilkan notifikasi di admin ketika pekerjaan diskon massal selesai untuk setiap produk.β
5 skill baru setiap minggu. 1 menit baca.
Cara kerjanya
Di server, kode mengirim pesan kepada pengguna yang memicu pekerjaan, tanpa membiarkan kegagalan pengiriman menggagalkan pekerjaan utama. Di aplikasi admin, handler menyaring pesan berdasarkan action-nya lalu bereaksi, misalnya dengan menampilkan notifikasi.
Konten teknis (SKILL.md asli)
Teks asli dari pembuat, dalam bahasa Inggris, langsung dari 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.
Pertanyaan umum
Versi Webiny apa yang dibutuhkan?
Skill ini menyebutkan bahwa notifikasi websocket membutuhkan Webiny 6.5.0 atau yang lebih baru.
Bagaimana jika pesan gagal dikirim?
Skill ini menyebutkan bahwa kegagalan websocket tidak boleh menggagalkan pekerjaan utama, jadi error hanya dicatat lalu diabaikan.
Siapa yang menerima pesan?
Pengguna yang memicu pekerjaan, yang ditemukan melalui konteks identitas.
Detail
Deskripsi asli dari pembuat
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
Popularitas
- Bintang GitHub
- 8.1k
- Peringkat
- #12592
- Lisensi
- β
- Diperbarui
- 2/11/2026
Komentar
- β¦
Skill lain dari repositori ini
prd-to-plan
8.1kMembantu agent Anda mengubah dokumen kebutuhan produk menjadi rencana bertahap yang terdiri dari irisan kecil dari ujung ke ujung, disimpan sebagai berkas Markdown.
webiny-admin-architect
8.1kMengajari agent Anda cara membangun layar admin untuk platform Webiny, dengan memakai lapisan logika bisnis dan pola presenter.
webiny-admin-permissions
8.1kMengajari agent Anda menambahkan kontrol izin ke layar admin Webiny, termasuk formulir izin yang dibuat otomatis dan pemeriksaan tampilkan atau sembunyikan.
webiny-form-model
8.1kMengajari agent Anda membangun formulir di Webiny dengan pembuat field deklaratif, tata letak, validasi, dan aturan bersyarat.
Skill serupa
api-connector-builder
280kMembuat agent Anda membangun koneksi API baru mengikuti pola yang sudah ada. Gunakan saat ingin menambah integrasi lagi tanpa membuat cara baru.
api-design
280kMembantu agent Anda merancang REST API sesuai praktik terbaik. Berguna untuk mengatur cara API berkomunikasi, menampilkan error, dan mengorganisasi data.
backend-patterns
280kMembantu agent Anda dengan pola arsitektur sisi server dan optimasi database. Berguna untuk membangun atau meninjau kode yang berjalan di server.