Custom messages

The Enterprise Communications API enables you to optionally define a more specific message body for a channel, allowing you to utilise all of the features supported by that channel.

See the section for each channel for more information on what content to populate the customBody property with. For example, Facebook's custom body.

Examples

{
  "body": "{{Test from Comapi}}",
  "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 Comapi",
  "to": {
    "phoneNumber": "447123123123"
  },
  "customBody": {
    "sms": {
      "from": "Comapi",
      "to": "447123123123",
      "body": "Hello, this is a test message",
      "deliverAfter": "2017-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, add {{profile.profile property name}} anywhere in the properties.

If you’re 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, the token is replaced with a blank string.

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 profile’s ID, use the {{profileId}} field.

{
  "body": "Hi {{profile.name}}, this body text can be merged in the customBody!",
  "to": {
    "profileId": "[email protected]"
  },
  "customBody": {
    "fbMessenger": {
      "text": "{{body}}"
    }
  },
  "rules": [
    "fbMessenger",
    "sms"
  ]
}