The Omnichannel API lets you define a more specific message body for a channel, allowing you to utilise all of the features supported by that channel. If you don't define a customBody for a channel we automatically create a message body using the text in the body property.
See each channels section for more information on what content to populate the customBody property with, for example, Facebook's custom body
Some examples of custom body content are:
{
"body": "{{Test from the Omnichannel API}}",
"to": {
"profileId": "**YOUR USER PROFILE ID**"
},
"customBody": {
"fbMessenger": {
"attachment": {
"type": "image",
"payload": {
"url": "https://scontent.xx.fbcdn.net/v/t1.0-1/p200x200/17156020_1871286216424427_1662368582524349363_n.jpg?oh=22685c22a19fc2e28e69634e6a920972&oe=592FD3D1"
}
}
}
},
"rules": [
"fbMessenger"
]
}
{
"body": "Test from the Omnichannel API",
"to": {
"phoneNumber": "447123123123"
},
"customBody": {
"sms": {
"from": "YourCompany",
"to": "447123123123",
"body": "Hello, this is a test message",
"deliverAfter": "2019-03-01T12:57:00.543Z",
"clientRef": "124546"
}
},
"rules": [
"sms"
]
}
We make it simple
If you only want to define a customBody for some of the channels you are targeting we automatically create a message body for the other channels based on the text in the body property.
Merge Fields
In custom bodies you can optionally use merge fields to merge in properties from the profile you are addressing the message to. To do this simply add {{profile. profile property name }} anywhere in the properties.
If you are creating a new profile with the send, then the merge field allows the merging of the data in the to property, and if no property value can be found a blank string replaces the token.
In addition to the profile merge fields you can reference the {{body}} and {{title}} properties of the request to avoid duplication.
If you want to reference the profiles id then use the {{profileId}} field.
e.g.
{
"body": "Hi {{profile.name}}, this body text can be merged in the customBody!",
"to": {
"profileId": "[email protected]"
},
"customBody": {
"fbMessenger": {
"text": "{{body}}"
}
},
"rules": [
"fbMessenger",
"sms"
]
}