First steps
Events and Behaviour Tracking
User Data
- Email Builder Review
- Designing your email
- Creating a Synchronized Module
- Setting Responsivity
- Building Smart Containers
- Creating a Gmail Promotions Annotation
- Adding a Rollover Effect
- Adding a Background to an Email
- Adding Anchor Links
- Adding a Video to an Email
- Adding a Table to an Email
- Adding a Custom Font
- Adding Social Media Buttons
- Editing HTML and CSS
- Working with “Images” block
Omnichannel
Automation
Personalization
Analytics
Multilanguage Campaigns
Recommendations
API
Security and Compliance
Integration
Promo Code Added via API
Let's see how to add promo codes to trigger messages using API methods:
- Generate event (via workflow),
- Send prepared message (without workflow).
Generate event method
The Generate event method allows you to send any custom events that can launch workflows.
To substitute a promo code transmitted via API into a trigger message, do the following:
- Set up the transfer of the necessary parameters in the event.
- Add a variable to the message.
- Create a workflow.
1. Setting event parameters
The event must contain a promo code and contact identifier for sending the message (e.g., an email address for sending an email or a phone number for SMS).
Event parameters:
{
"params": [
{
"name": "EmailAddress",
"value": "mail@example.com"
},
{
"name": "code",
"value": "ABC-123"
}
]
}
, where code is the variable's name used in the message, and ABC-123 is the promotional code the contact will receive.
2. Substituting variable in the message
Insert the variable's name containing the promo code into the message in the $!data.get('code') format. Instead of a variable, the contact will see the promo code passed in the event.
3. Creating the workflow
In the message block in the workflow, specify the event parameter that contains the contact identifier for sending the message (in our example, this is an email address; for other channels, use the appropriate IDs).
Read more about launching a workflow on an event in the instructions.
Send Prepared Message Method
The Send prepared message method allows you to send campaigns to one or more contacts.
You can send a unique promo code to each contact.
Request format:
{
"recipients": [{
"locator": "mail@example.com",
"jsonParam": "{\"code\":\"ABC-123\"}"
}],
"email": true
}
, where the recipients array contains elements with jsonParam. It can be used to send any data to a message, including a promo code. The data for the message must be in JSON format converted to a string.
Use message ID instead of {id} in https://esputnik.com/api/v1/message/{id}/smartsend request.
In the message, use a variable in the $!data.get('code') format.