Skip to content

Commit

Permalink
chore: add per-user prop example to alerting guide (#777)
Browse files Browse the repository at this point in the history
  • Loading branch information
JEverhart383 authored Feb 21, 2025
1 parent 6000df6 commit 2d000b5
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions content/guides/alerting.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,20 @@ Subscriptions can also hold their [own unique properties](/concepts/subscription
```javascript title="Subscribe a user to an alert Object"
knock.objects.addSubscriptions("alerts", alertId, {
recipients: ["user_79bc96a9", "user_JG9NGAJQ", "user_391d92cd"],
properties: {
channels: ["email", "in_app"],
events: ["maintenance", "compliance"],
batchWindow: {
frequency: "weekly",
days: ["fri"],
hours: 17,
},
},
});
```

Once you've stored these properties on a subscription, you can access them inside the workflow run on `recipient.subscription.channel` or `recipient.subscription.events` for use in either templates or step conditions. This allows you to create a highly configurable alerting system that can be customized on a per-user basis.

### Triggering an alert

To trigger an alert workflow, your application would only need the `id` of the alert you want to trigger. From there, you would fetch the `alert` Object from Knock (we’re working on some ways to more easily reference objects inside of workflow runs).
Expand Down

0 comments on commit 2d000b5

Please sign in to comment.