Sending a Custom Message
Sending custom messages from an external trigger
Raisely supports a lot of ways to trigger an email and these will usually satisfy your needs, but if you're building something that's very custom, you can set up messages to respond to "Custom Event (API Only)".
(See Customise Your Email Triggers)
To trigger these messages, you'll need to send a custom event to the Raisely communications API each time you want them to send.
Setting up Multiple Custom Triggers
If you are setting up multiple custom triggers, you'll need to use an audience condition to differentiate events so that one event doesn't cause all custom triggers to send.
Here's an example payload you would send to trigger a custom message.
// POST https://communications.raisely.com/v1/events
// Authorization: Bearer raisely:[your-api-key]
{
"data": {
"version": 1,
"type": "raisely.custom",
// Used to match this event to your trigger,
// so make sure this is set to the campaign that
// you have created a matching trigger in
"source": "campaign:YOUR-CAMPAIGN-UUID",
// Alternatively, you can match on your organisation
// messages
// "source": "organisation:YOUR-ORGANISATION-UUID",
// The payload for the event
// This can be anything you want, but you probably want
// to include a user object so that you can use
// the email and name fields for mail merging
"data": {
"user": {
"email": "[email protected]",
"fullName": "Recipient Person",
"preferredName": "Recipient",
},
"custom": {
"trigger": "step-1",
"message": "This is a custom message",
},
}
}
}
curl --location 'https://communications.raisely.com/v1/events' \
--header 'Authorization: Bearer raisely:[your-token]' \
--header 'Content-Type: application/json' \
--data-raw '{
"data": {
"version": 1,
"type": "raisely.custom",
// Used to match this event to your trigger,
// so make sure this is set to the campaign that
// you have created a matching trigger in
"source": "campaign:YOUR-CAMPAIGN-UUID",
// Alternatively, you can match on your organisation
// messages
// "source": "organisation:YOUR-ORGANISATION-UUID",
// The payload for the event
// This can be anything you want, but you probably want
// to include a user object so that you can use
// the email and name fields for mail merging
"data": {
"user": {
"email": "[email protected]",
"fullName": "Recipient Person",
"preferredName": "Recipient"
},
"custom": {
"trigger": "step-1",
"message": "This is a custom message"
},
}
}
}'
All merge fields must be in the payload you send
All the fields in your payload can be used for audience conditions and mail merge in the message body and subject.
Any merge fields you want to use must be present in the payload as the Raisely system makes no assumptions about a custom message event, or what records it refers to.
Set the audience
A custom trigger can be used with any audience. It's usually best to set the one that most closely matches your scenario so it's easier to make use of merge fields for those type of messages. To do this correctly, it's important to know the object shape that is assumed when choosing recipients.
Audience | Recipient object | Recipient email attribute |
---|---|---|
Fundraisers & Team Leaders | profile.user | profile.user.email |
Donors | donation | donation.email |
Everyone | user | user.email |
Audience Conditions
When setting up the audience, you can type arbitrary JSON paths in the audience conditions. Use dot notion to locate different attributes in the payload.
For example, to match the example JSON event above, you could use custom.trigger
is
step-1
Mail Merge
Use handlebars syntax ({{field.path}}) to insert custom fields into the message.
Updated over 1 year ago