Override Recipient
Learn what override recipient setting in trigger node
The "recipient" refers to either a single user or a group of users who will be receiving a notification. By default, the user who initiates the event (specified by the distinct_id
parameter in the track event call) will be considered the recipient.
However, there may be situations where you do not want the notification to be sent to the user who initiates the action. For instance, when John shares a document with Olivia for review and Olivia adds comments to the document, you would want to inform John that he has received new comments on the shared document.
To handle such cases, you can override the default recipient with another identifier specified in the event property. For example, if this is the event call, you can pass .recipient
in the recipient field to send the notification to [email protected]
distinct_id = "0fxxx8f74-xxxx-41c5-8752-xxxcb6911fb08" # Unique id of user in your application
event_name = "product_purchased" # name of the event you're tracking
# Properties: a dict representing event-attributes
properties = {
"first_name": "User",
"spend_amount": "$10",
"recipient":"[email protected]"
}
event = Event(distinct_id=distinct_id, event_name=event_name, properties=properties)
You can add recipient as a JQ-expression. Below are some examples of how to enter recipients in the workflow:
- To enter an array of recipients, something like
"recipients": ["recipient1","recipient2","recipient3"]
, enter in the format.recipients[]
. It would send the notification to all the recipients in the array. - If the recipient is a nested event property key like shown below, enter it in the format
.recipient.id
.
properties = {
"recipient": {
"name": "Steve",
"id": "0exxx9g12-xxxx-31b5-8752-xxxcb7860fb07"
}
}
- In the below array object example, if you want to send notifications to all the admins of an organization, enter the format
.organization.admins[].user_id
.
properties = {
"organization":{
"id":"1234",
"admins": [
{
"user_id":"0exxx9g12-xxxx-31b5-8752-xxxcb7860fb07",
"name":"Olivia"
},
{
"user_id":"1gxxx5a32-xxxx-73b3-9854-xxxqw7891fb07",
"name":"Steve"
}],
"members": [
{
"user_id":"4txxx9a18-xxxx-71f5-0876-xxxmn7908fb07",
"name":"Amy"
},
{
"user_id":"5yxxx0n23-xxxx-90f5-0746-xxxmn9081fb91",
"name":"Jane"
}
],
"location":"San Francisco"
}}
Updated 11 months ago