Triggering a campaign with custom email tokens per lead

Anonymous
Not applicable

Triggering a campaign with custom email tokens per lead

I am working on sending transactional emails via the trigger campaign REST API. The endpoint seems to take a list of leads. My understanding from this article is that it is not possible to supply custom program tokens per lead?

For example, let us say I have a "Welcome" email that is sent shortly after signup. The email includes a custom message that is different for each user, and this message is supplied by a {{my.customMessage}} token. My understanding is that I cannot trigger the campaign with JSON like this, where the email tokens for each lead is respectively taken from the "tokens" field:

{

  "input": {

    "leads": [

      {

        "id": 0

      },

      {

        "id": 1

      },

      {

        "id": 2

      }

    ],

    "tokens": [

      [{

        "name": "{{my.customMessage}}",

        "value": "Custom message for lead 0"

      }],

      [{

        "name": "{{my.customMessage}}",

        "value": "Custom message for lead 1"

      }],

      [{

        "name": "{{my.customMessage}}",

        "value": "Custom message for lead 2"

      }],

    ]

  }

}

My understanding is that the only batching I can do through the trigger campaign API would be the following, where the leads all get the same message:

{

  "input": {

    "leads": [

      {

        "id": 0

      },

      {

        "id": 1

      },

      {

        "id": 2

      }

    ],

    "tokens": [

      {

        "name": "{{my.customMessage}}",

        "value": "Custom message for lead 0, 1, 2"

      },

    ]

  }

}

Is this correct? I am just trying trigger batch and send multiple emails with custom tokens in a single API request.

Tags (1)
1 REPLY 1
SanfordWhiteman
Level 10 - Community Moderator

Re: Triggering a campaign with custom email tokens per lead

Temporary Program-level {{my.tokens}} such as those used by the Request and Schedule Campaign endpoints are global to the job.

Of course, depending on your load and requirements, you could set a permanent Program-level {{my.token}} instead. This could be a Velocity token (not permitted as a temporary token) that stores the custom messages for all your leads in an ArrayList.