You can send a personalized push notification to a specific user from an external trigger by combining the /postEvent API method with a Customer Journey. This is ideal for transactional notifications such as order status updates.
1. Create the event and the push preset
- Create the event (for example
OrderReady) in Audience > Events, and declare the attributes you will send (for examplename,item). - Create a Push preset in Content > Push presets. Personalization in a journey works on presets only — custom content typed into the journey element can be personalized with Tag values, not with event attributes.
- In the preset text, insert Liquid objects that reference the placeholder/tag names, in double curly braces. Pushwoosh Liquid objects are plain names — there is no
event_attribute.namespace:Hi {{ name | default: "there" }}! Your {{ item | default: "order" }} is ready for pickup.
2. Build a Trigger-based Journey
- Create a Customer Journey and drop a Trigger-based entry element on the canvas. Select the
OrderReadyevent as the trigger. - Leave Who enters the campaign? on the default Users who perform the event. (Use Users from an event attribute only when you pass someone else's User ID in an attribute.)
- Add a Push element after the entry and select the preset you created.
- On the Push element, enable Personalize message with event attributes (Dynamic Content) or Overwrite Liquid placeholders and pick the entry event, so the attribute values fill the placeholders. Attribute names must match the placeholder/tag names used in the preset.
3. Trigger the Journey with a postEvent call
Send a POST request to /postEvent. Authenticate with your Device API token (not the Server API token) in the Authorization header. The body must contain application, event, attributes (may be empty but must not be omitted), and userId and/or hwid.
curl --request POST \
--url https://api.pushwoosh.com/json/1.3/postEvent \
--header 'Authorization: Token YOUR_DEVICE_API_TOKEN' \
--header 'Content-Type: application/json' \
--data '{
"request": {
"application": "XXXXX-XXXXX",
"userId": "u12345",
"event": "OrderReady",
"attributes": {
"name": "John",
"item": "Latte"
}
}
}'
The user with User ID u12345 enters the journey and receives: "Hi John! Your Latte is ready for pickup."
Note: the User ID must already have at least one registered device. A User ID with no associated device cannot enter a journey.
Comments
0 comments
Please sign in to leave a comment.