pentacent / keila

Open Source Newsletter Tool.
https://keila.io
GNU Affero General Public License v3.0
1.36k stars 67 forks source link

Add campaign data #103

Closed wmnnd closed 2 years ago

wmnnd commented 2 years ago

Campaigns, just like contacts, should allow for custom data in the shape of a data jsonb field. This will allow the use of templates with Liquid to generate emails based on that data.

dpraul commented 2 years ago

Very exciting to see this feature in the roadmap! Definitely going to follow this feature and product as you build it out. As you encouraged people to do, I just wanted to give my 2c on how this might be used in-practice.

We're currently using a lot of programmatic sugar around the MailChimp campaign data feature (via their "editable areas" template language) to send data-driven newsletters on a regular basis. I do not necessarily think MailChimp is the best tool to do this, as we're definitely flexing it quite a bit, but it does the job.

MailChimp only allows the campaign data to be used via their template language, which is very weak (and afaik doesn't even exist in their newer template types), so we actually embed handlebars inside of the editable regions to make the templates more powerful. We stole this idea from this Contentful blog post from 2018. We chose handlebars simply because it is lightweight, but I have found we have to write lots of helpers to make it powerful enough to do everything we want.

We have a regular cronjob setup that pulls data from our API, applies it to a Mailchimp campaign, and sends it. The workflow, currently, is:

  1. Kick off the cronjob by fetching a "base" campaign from MailChimp.
    • We start it with a pre-existing campaign just so that administrators can use the MailChimp UI to easily adjust facets of the campaign to be applied to future emails (i.e. leverage MailChimp for what it's good for - the UI)
    • The campaign must be configured with an HTML template, which (as far as I know) is the only MailChimp template type that supports the campaign data feature
  2. Create a new campaign using all of the settings of the prior
  3. Fetch the default content for the editable fields of the campaign's template.
    • These fields are where we embedded the handlebars markup
  4. Use handlebars to compile each of the editable fields with data from our API
  5. Attach these compiled fields as the campaign data to the new campaign we created earlier
  6. Send the campaign

It seems that the implementation as you've described it in your twitter thread would very easily fit nearly this exact workflow (and you've already built-in a much more powerful and friendly templating language!) - which is incredibly cool to see. I don't have much more to input since I haven't used keila at all, but I hope this input is useful in how you shape this feature!

wmnnd commented 2 years ago

@dpraul Thank you so much for your input. This is exactly one of the use-cases I had in mind when designing this feature, so I hope you’ll find it useful once it’s been implemented!

wmnnd commented 2 years ago

This feature has now been implemented via #104 :partying_face:

@dpraul I’m looking forward to hearing from you what you think.