How to Use AI to Generate Personalized Marketing Content

Create personalized marketing messages for different customer segments using AI.

What This Integration Does

Generic broadcasts get ignored. This workflow uses Spojit's AI Agent to write copy that lands - product recommendations grounded in what each segment actually buys, seasonal offers in their voice, and subject lines tuned to the segment. The result is more opens, better click-through, and less time spent in the copy doc.

The workflow runs on a schedule (typically weekly before your send window). For each segment it pulls fresh profile data from Klaviyo, asks a Knowledge node for relevant products, sends both to the AI Agent for copy generation, then writes the copy back to Klaviyo as a custom property the campaign template can read.

Prerequisites

  • A Klaviyo connection with read and write access to profiles and lists.
  • A Spojit Knowledge collection populated with your product catalog (titles, descriptions, hero images, price bands, tags).
  • A list of segment names that match real Klaviyo lists or profile properties (e.g. vip, new, at-risk, bargain-hunter).
  • Klaviyo campaign templates that read the custom property you write copy into.

Step 1: Schedule Trigger

Drop a Trigger node and set its type to Schedule. Weekly on Monday 06:00 is a good default if your team sends mid-week. The trigger fires once per run; the next steps handle the fan-out across segments.

Step 2: Fetch Segments and Profiles from Klaviyo

Add a Connector node pointing at klaviyo and pick the list-lists tool to enumerate segment lists. Wrap a Loop around the result and inside it call list-profiles, filtered by the current list id, to get a sample of profiles per segment. You only need 10-20 profiles per segment for the AI to learn the voice - you do not need to pull the whole list.

Step 3: Knowledge Lookup for Relevant Products

Inside the same loop, add a Knowledge node that queries your product catalog collection. Pass the segment name and a short profile summary as the query - for example, top categories for {{ segment.name }}: {{ profileSummary.topCategories }}. The node returns the 5-10 most relevant products with descriptions and images. This is what keeps the AI from hallucinating SKUs.

Step 4: AI Agent Generates Copy

Add an AI Agent node. Give it a structured output schema so downstream steps can read individual fields:

{
  "subjectLine": "string",
  "preheader": "string",
  "heroHeadline": "string",
  "bodyHtml": "string",
  "ctaLabel": "string",
  "featuredProductIds": ["string"]
}

Prompt: You are writing a marketing email for the {{ segment.name }} segment. Use the tone notes for that segment. Recommend at most 3 of these products: {{ knowledgeResults }}. Keep subject lines under 60 characters and preheaders under 90.

Step 5: Write Copy Back to Klaviyo

Add a Connector node on klaviyo with the update-profile tool. For each profile in the segment, set custom properties:

  • ai_subject_line - the generated subject
  • ai_preheader - the preheader
  • ai_hero_headline - the headline
  • ai_body_html - the body block
  • ai_generated_at - timestamp so the template can show freshness

If you would rather push to a campaign instead of per-profile, generate one copy block per segment and store it in a single profile-level field on a "campaign config" profile.

Step 6: Trigger or Schedule the Klaviyo Campaign

You have two options. The simplest is to let your scheduled Klaviyo campaign pick up the new custom properties on its next send. The more reactive option is to add a Connector step at the end that calls create-event with an event name like ai_copy_ready, then trigger a Klaviyo flow on that event.

Tips

  • Cap generations per segment per week - re-running the workflow more often than your send cadence wastes tokens and confuses A/B reads.
  • Store the segment's tone notes ("playful and short" vs. "premium and restrained") in the Knowledge collection so changes do not require editing the prompt.
  • Log every generation to a mongodb collection so you can later correlate copy with open rate.

Common Pitfalls

  • Hallucinated products - if you do not constrain the AI to featuredProductIds drawn from the Knowledge results, it will invent SKUs. Validate the ids exist before pushing to Klaviyo.
  • Subject line length - mobile clients truncate around 40-60 characters. Enforce it in the schema and re-prompt on overflow.
  • Klaviyo property limits - very large HTML bodies can hit the per-property size cap. Store long bodies in a hosted location and reference a URL instead.

Testing

Run the workflow once manually against a single test segment that contains only your own email address. Open the resulting Klaviyo profile and check that all ai_* properties are populated. Send yourself the campaign as a preview before scheduling the real send.

Learn More

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.