Using Velocity in Mobile Push
See how to create mobile push with dynamic variables. Similarly you can use variables in SMS and web push notifications
As an example, we'll use an order confirmation mobile push message and add dynamic subscription details to it.
- Go to Messages → Messages and open the necessary Mobile push or create a new one.

- Use Velocity to add dynamic variables to content where personal contact data should be substituted. The number of variables and their names will depend on your copy.
Let's see how the Velocity code will look in the message using the SubscriptionStarted Event as an example.
{
"eventTypeKey": "SubscriptionStarted",
"params": {
"externalCustomerId": "a7c9f9b8-d3a2-401c-8b93-7f3d4f91bfa2",
"subscriptionPlan": "Premium",
"startDate": "2024-01-01T12:00:00Z",
"price": 49.99,
"currency": "USD",
"billingCycle": "Monthly"
}
}
Having the params
object, the Velocity code looks as follows:
Plan: $!data.get('params').get('subscriptionPlan')
Price: $!data.get('params').get('price') $!data.get('params').get('currency')
Billing cycle: $!data.get('params').get('billingCycle')
Start date: $!data.get('params').get('startDate')

NoteThe data retrieval command data.get is required only when accessing external data sources. In all other cases, you can also use the format described in the Velocity 2.4.1 documentation. For example:
Format Variable Description Shorthand $discount
If the variable does not exist, the literal text $discount
is outputSilent $!discount
If the value is missing, nothing is rendered Formal ${discount}
Braces unambiguously delimit the variable name from adjacent text Silent formal $!{discount}
Properly delimits the variable and suppresses missing values Alternate value ${discount|Free Shipping}
If the variable value is missing, a fallback value is inserted
The following content is the result of substitution, the design of the notification may differ depending on the OS version:

Updated 6 days ago