MoEngage
Before You Start
Section titled “Before You Start”- Identify your JustAI org slug (usually your company name in all lower case - feel free to ask us).
Set up a JustAI test in MoEngage
Section titled “Set up a JustAI test in MoEngage”Create a Content API pointing to JustAI
Section titled “Create a Content API pointing to JustAI”- In MoEngage, go to Settings → Advanced → Content APIs → Add.
- Name it something like
JustAIand set the URL to your JustAI content endpoint:https://worker.justwords.ai/api/generate/<org_slug>?template_id=<template_id>- Headers:
X-Api-Key: JW_API_KEY
- Enable parameters you’ll pass (e.g.,
user_id,gender,cohort, etc.).
Example usage in your MoEngage email content (treatment path):
{# Call the Content API you added as "JustAI" #}{% set jw = ContentApi.JustAI({ "params": { "email": UserAttribute['Email']|default(''), "user_id": UserAttribute['ID']|default(''), "gender": UserAttribute['Gender']|default('') }, "static_params": {}, "dynamic_params": {}, "request_body": {}}) %}
{# Insert HTML returned by JustAI #}{{ jw.copy.vars.body }}
{# Optional for analytics/debugging #}<!-- JW_COPY_ID: {{ jw.copy.id|default('') }} -->Notes:
- You can also personalize Subject/Preheader using values from
UserAttribute[...]and safe defaults. - If your workspace exposes a different helper (e.g.,
contentapi('JustAI', params={...})), adapt the call accordingly.
Build the experiment in Flows
Section titled “Build the experiment in Flows”- Flows → Add “A/B Split”. Put your standard email on Path A (Control).
- Clone to Path B (Treatment) and replace the content with the block above that calls the JustAI Content API.
Send metrics back to JustAI (control & treatment)
Section titled “Send metrics back to JustAI (control & treatment)”Option A — MoEngage Streams (recommended, near‑real‑time)
Section titled “Option A — MoEngage Streams (recommended, near‑real‑time)”- Ask MoEngage to enable Streams for your account.
- Configure Streams → Destination: HTTPS/Webhook to your JustAI events endpoint with auth.
https://worker.justwords.ai/api/webhook/moengage/<org_slug>
- Select campaign interaction events (Email Sent, Open, Click, Unsubscribe, Bounce, etc.).
- Include identifiers in the payload:
campaign_id,variation_id(A/B path),event_time,user_id,email, and any custom properties you add (e.g.,jw_copy_idif you inject it into the HTML as a hidden comment or link param).
Example transform → JW event (illustrative):
{ "platform": "moengage", "channel": "email", "event": "email_click", "campaign_id": "{{campaign_id}}", "variation_id": "{{variation_id}}", "user_id": "{{user_id}}", "email": "{{email}}", "timestamp": "{{event_time}}", "metadata": { "flow_id": "{{flow_id}}", "link_id": "{{link_id}}", "jw_copy_id": "{{jw_copy_id}}" }}How JustAI uses it: We join Streams events (by user_id/email, campaign_id, timestamp) with the content-serve logs from the JustAI Content API (which include copy_id). That yields per‑copy and per‑branch (control vs treatment) opens/clicks.
Option B — Warehouse/S3 exports (batch)
Section titled “Option B — Warehouse/S3 exports (batch)”If Streams isn’t available, configure S3 exports (or Redshift/BigQuery/Snowflake) and let JustAI ingest daily drops under an org‑specific prefix. Export the same event set (sends/opens/clicks/unsubs) with campaign_id, variation_id, and user identifiers for attribution.
Testing copy for first‑name personalization & segment variations
Section titled “Testing copy for first‑name personalization & segment variations”First‑name personalization (with safe fallbacks)
Section titled “First‑name personalization (with safe fallbacks)”{% set first = UserAttribute['First name'] %}{% if first %} Hi {{ first }},{% else %} Hi there,{% endif %}Tip: Use defaults everywhere you reference user attributes. If your workspace supports a “do not send” fallback token, you can gate certain sends on presence (e.g., default to a token that suppresses the message) — otherwise, branch in the Flow or segment.
Gender (or any attribute) segmentation
Section titled “Gender (or any attribute) segmentation”- Ensure attributes (e.g., Gender) are tracked on user profiles.
- Create segments in Segments → Create Segment (e.g.,
Gender == 'Male',Gender == 'Female', etc.). - In your treatment path, pass these attributes to the JustAI Content API (
gender,cohort,lifecycle_stage, etc.) so JustAI can return segment‑specific variants. - Optionally run A/B inside each segment to select segment‑specific winners.