Test all Pinglet notification types in real-time. Configure, preview the payload, and send.
Trigger real DOM CustomEvents on the user's browser when they click a notification button. Your frontend JS listens for the event and runs any logic — add to cart, open a modal, track conversions, and more.
window.dispatchEvent(new CustomEvent("name", { detail: payload }))textstringrequiredButton label shown to the user
action"event"requiredMust be exactly "event"
eventstringrequiredCustom event name (e.g. "pinglet:addToCart")
dataanyPayload sent as event.detail — object, array, string, number
| Action | Required | Behavior |
|---|---|---|
redirect | src (URL) | Opens URL in new tab |
link | src (URL) | Opens URL in same tab |
alert | src (string) | Shows browser alert |
reload | — | Reloads the page |
close | — | Dismisses notification |
event | event (string) | Fires CustomEvent on window |
onClick | onClick (fn) | Evaluates inline function |
curlcurl -X POST https://your-api/api/v1/notifications/send \
-H "Content-Type: application/json" \
-d '{
"type": "2",
"projectId": "your-project-id",
"body": {
"title": "Flash Sale!",
"description": "50% off — limited time only",
"icon": "https://example.com/sale-icon.png",
"buttons": [
{
"text": "Add to Cart",
"action": "event",
"event": "pinglet:addToCart",
"data": {
"productId": "SKU-123",
"quantity": 1,
"discount": 50,
"source": "flash-sale-notification"
}
},
{ "text": "Maybe Later", "action": "close" }
]
}
}'1. Include Pinglet SDK (already done if notifications work)
2. Add your event listener AFTER the SDK script
html<script>
window.addEventListener("pinglet:addToCart", function (e) {
console.log("Payload received:", e.detail);
addItemToCart(e.detail.productId, e.detail.quantity);
});
</script>3. Send notification with event button (API / curl / dashboard)
4. User clicks → your listener fires with e.detail
Register in a lifecycle hook and clean up on unmount.
tsxuseEffect(() => {
const handler = (e: CustomEvent) => {
console.log("Event data:", e.detail);
// Your logic here
};
window.addEventListener("pinglet:addToCart", handler);
return () => window.removeEventListener("pinglet:addToCart", handler);
}, []);Add to Cart
event: "shop:addToCart"data: { productId, variant, price }Open Modal
event: "ui:openModal"data: { modalId, productSlug }Track Conversion
event: "analytics:conversion"data: { campaign, value, currency }SPA Navigation
event: "app:navigate"data: { path, tab }Start Chat
event: "support:openChat"data: { department, priority }Apply Coupon
event: "promo:applyCoupon"data: { code, discount, minOrder }Theme Toggle
event: "theme:toggle"data: { theme: "dark" }data accepts any JSON type: object, array, string, numberwindow.dispatchEvent(new CustomEvent("your:event", { detail: { test: true } }))// Minimal — just event name
{ "text": "Click Me", "action": "event", "event": "app:clicked" }
// With object data
{ "text": "Buy", "action": "event", "event": "shop:buy", "data": { "id": 1 } }
// With array data
{ "text": "Select", "action": "event", "event": "bulk:select", "data": [1, 2, 3] }// Missing "event" field
{ "text": "Click", "action": "event" }
// "event" is not a string
{ "text": "Click", "action": "event", "event": 123 }
// Wrong action type
{ "text": "Click", "action": "customEvent", "event": "x" }