Summary
In this recipe, we’ll walk through how to use a daily churn prediction model—hosted on AWS SageMaker and running on pre-aggregated data in S3—to trigger Einstein GPT for generating personalized partner re-engagement messages in Salesforce Marketing Cloud.
The Business Use Case
You’re part of a Martech or data team at a CPG enterprise that sells through B2B distributors and resellers. Partner engagement is critical, but lately, your sales teams are missing signs of disengagement.
To fix this, you run a daily churn model to identify at-risk partners. When a partner is flagged, you want to trigger a GPT-powered outreach that delivers timely, personalized re-engagement messaging across email, WhatsApp, and CRM follow-up, without manual intervention.
Pipeline Overview
We’ll implement a six-stage pipeline:
- Model runs daily over pre-aggregated data in S3
- Scores are filtered and enriched
- Platform events are pushed into Salesforce
- Salesforce Flow triggers Einstein GPT
- GPT generates a custom message
- Marketing Cloud sends the message via Journey Builder
Tools used
Tool / Service | What It Does in the Pipeline |
Amazon S3 | Stores pre-aggregated input data and model inference outputs (CSV/JSON). |
AWS SageMaker | Hosts and runs the daily churn prediction model via batch transform job. |
AWS Step Functions | Orchestrates the pipeline: invokes SageMaker, handles flow control and errors. |
AWS EventBridge | Triggers the Step Function execution on a daily schedule (e.g., 2 AM daily). |
AWS Lambda | Post-processing: filters high churn scores, enriches with metadata, and pushes events. |
Salesforce Platform Events | Used to asynchronously notify Salesforce of high-risk partners from Lambda. |
Salesforce Flow Builder | Listens to platform events, looks up account info, and calls Einstein GPT. |
Einstein GPT Studio | Generates personalized outreach messages using dynamic prompts. |
Salesforce Custom Object (Generated_Message__c) | Stores GPT-generated messages for review and campaign sync. |
Salesforce Marketing Cloud (Journey Builder) | Sends email/WhatsApp follow-ups using the GPT messages. |
Triggering Salesforce Flow using AWS Step Function
The first part of this pipeline is executed inside AWS using an AWS Step Function that implements the following steps

Step 1: Daily Model Execution on Pre-Aggregated Data
This is the first node of the AWS Step Function that is used to automate this pipeline.
Notice that the data used by the churn prediction model is kept in an S3 bucket. In this recipe, we are not concerned with what this data represents. The model takes this data and outputs a churn score for each customer.
- Data Source: s3://company-data/churn_inputs/
- Data Format: Parquet files, partitioned by date
- Example Schema:
partner_id | days_since_last_order | sku_range | engagement_score | region | tier
- Model Host: AWS SageMaker Batch Transform or Processing Job
- Schedule: Daily at 2 AM (via EventBridge rule or Airflow)
🔧 Output Format (CSV or JSON written back to S3):
[
{
“partner_id”: “DISTR_1098”,
“churn_score”: 0.84,
“top_factors”: [“No orders in 60 days”, “Low SKU diversity”],
“prediction_date”: “2025-06-13”
}
]
- Output location: s3://company-data/churn_scores/YYYY-MM-DD/scores.json
Step 2: Threshold Filtering and Metadata Join
A lightweight ETL job (e.g., Lambda/Glue/Fargate) runs immediately after scoring:
- Pulls the new prediction file from S3
- Filters churn_score > 0.75 (configurable via step function runtime parameters)
- Joins with metadata to map partner ID to Salesforce Account ID and rep details
Output Schema (for event generation):
{
“partner_id”: “DISTR_1098”,
“churn_score”: 0.84,
“account_id”: “001ABC000000XY”,
“region”: “East”,
“partner_name”: “ABC Traders”,
“rep_name”: “John Reilly”,
“top_factors”: [“No orders in 60 days”, “Low SKU diversity”]
}
Step 3: Push Salesforce Platform Event
Each filtered record is pushed to Salesforce as a Platform Event: Partner_Disengagement_Alert__e. This is done using a Lambda function that calls the Salesforce REST API. The Lambda is encapsulated within a mode in the AWS Step Function flow.
Example Payload:
{
“Partner_ID__c”: “DISTR_1098”,
“Churn_Score__c”: 0.84,
“Region__c”: “East”,
“Partner_Name__c”: “ABC Traders”,
“Rep_Name__c”: “John Reilly”,
“Top_Factors__c”: “No orders in 60 days, Low SKU diversity”,
“Triggered_At__c”: “2025-06-13T03:00:00Z”
}
Salesforce Flow is configured to trigger when this event is received.
Running the AWS Step Function on a Schedule
The AWS Step Function above can be scheduled using Amazon EventBridge (formerly CloudWatch Events). This creates a serverless, event-driven trigger for your business workflow. Simply go to the EventBridge section and create a new schedule with the target as Step Function above.
From AWS to Salesforce: The System Boundary
The first half of this pipeline (Steps 1–3) runs within AWS.
The following steps — Steps 4–6 — are executed within Salesforce, using Flow Builder, Einstein GPT Studio, and Marketing Cloud to complete the outreach loop.

Step 4: Generate a Message Using Einstein GPT Studio
This is the first step within the Salesforce flow (generated using Flow Builder), and it does the following:
- Looks up the relevant Account record using Partner_ID__c from the platform event
- Retrieves related data (Account Manager, Region, Tier, etc.)
- Constructs a dynamic prompt
- Invokes Einstein GPT Studio via a configured Action
Example Prompt:
Write a personalized email to {Partner_Name}, a distributor in {Region}, showing disengagement signs such as: {Top_Factors}. Their account manager is {Rep_Name}. Tone should be professional and supportive.
Einstein GPT returns a message like:
Hi ABC Traders,
We’ve missed hearing from you and wanted to share some new offers tailored for your region. John Reilly is available for a quick reconnect call this week.
Step 5: Store the GPT Output in Generated_Message__c
In this step, you store the generated message in a data extension.
What Happens:
- A new record is created in a custom object Generated_Message__c
- Fields saved include:
- GPT prompt and response
- Account ID
- Partner ID
- Churn Score
- Top Factors
- Status (e.g., Draft, Approved)
- Timestamp
Purpose:
- Acts as a message queue, audit log, and source for marketing automation
- Enables optional review/approval workflows
Step 6: Trigger a Marketing Cloud Journey
What Happens:
- Approved Generated_Message__c records are synced to a Marketing Cloud Data Extension
- A Journey Builder automation is triggered every time a new record is added
Typical Journey Steps:
- Email → Uses GPT response as body
- WhatsApp → Short summary of GPT message
- Task → Assign follow-up to the account manager
Monitoring and Consolidated Logging
To ensure observability across the full pipeline, spanning both AWS and Salesforce, it’s important to implement consolidated logging and traceability for each execution instance.
Logging in AWS (Steps 1–3)
- Step Functions: Enable CloudWatch Logs to capture execution history and failures.
- Lambda Functions: Log filtered partner IDs, payloads sent to Salesforce, and API response statuses.
- Optional Audit Log: Store per-partner log entries in a DynamoDB table or S3 audit log with fields like partner_id, churn_score, event_published, timestamp.
Logging in Salesforce (Steps 4–6)
- Platform Event Logs: Create a custom object (e.g., Event_Log__c) to capture when Partner_Disengagement_Alert__e is received.
- Message Tracking: The Generated_Message__c object already stores GPT prompts, completions, and metadata, which can be used for auditing and QA.
- Journey Tracking: Use the Journey_Triggered__c checkbox and standard Marketing Cloud tracking tools to monitor delivery outcomes.
Optional: Centralized Monitoring Dashboard
You can push logs from both platforms into a central reporting layer (e.g., Redshift, Snowflake, or Amazon OpenSearch) to visualize:
- Daily partner churn scores and GPT response generation
- Success/failure of each pipeline stage
- GPT performance and prompt effectiveness over time
This consolidated approach helps teams debug issues quickly, measure pipeline health, and provide compliance-ready visibility into AI-assisted messaging activity.
Conclusion: From Insight to Action, Fully Automated
In this recipe, we’ve gone beyond just detecting disengaged partners — we’ve built a fully automated, cross-platform pipeline that turns predictive churn insights into real-time, personalized marketing actions using Einstein GPT.
This is a blueprint not just for churn intervention, but for how to productionize AI inside your Salesforce Marketing Cloud ecosystem — safely, scalably, and with measurable business impact.
Looking ahead, the same pipeline pattern can be adapted for lead scoring, upsell readiness, product recommendation triggers, and more, wherever predictive insights can drive proactive messaging.