AI-generated Email Sequences in Beefree SDK with Claude AI
Create AI-generated Email Sequences in Beefree SDK with Anthropic's Claude AI and Simple Schema
Overview
This recipe explains how to build an AI-powered email sequence creation system that generates three strategically designed emails using Anthropic's Messages API, along with the Claude Sonnet 4 model, and converts them to full Beefree SDK templates using both Simple Schema and the Content Services API.
This recipe covers:
Simple Schema: Understanding the template structure and unified schema for multiple emails.
Anthropic API Integration: Structuring sequential API calls with different contexts for each email type.
Frontend Integration: Capturing end user email descriptions and managing progressive UI updates for multiple email generation.
Response Parsing: Extracting and validating JSON from multiple AI responses with error correction loops.
Beefree SDK Integration: Converting multiple simple templates to full templates and managing navigation between emails.
Reference the complete code for this project in the multiple-versions-concept folder inside the Simple Schema GitHub repository.
Prerequisites
Node.js
Beefree SDK credentials
Understanding of Beefree SDK's Simple Schema
Knowledge of Beefree SDK's Content Services API and
/simple-to-full-json endpoint
Core Concepts and Steps
This section details all of the core concepts required to integrate AI-generated email sequences within Beefree SDK. It includes descriptions of each concept, sample code, and the complete implementation at the end, along with customization tips.
As a reminder, the complete code for this recipe is available for reference in GitHub.
The following video shows the final result, and how the code for this recipe looks when you run it locally on your machine.
The following diagram shows how these core concepts relate to one another to create the experience shown in the video above.

1. Simple Schema Structure for Sequences
Simple Schema is a simplified JSON format that makes it easy to generate email templates programmatically. It uses a hierarchical structure with templates, rows, columns, and modules. Understanding and using Simple Schema is critical for building AI-powered workflows, because it's simpler JSON makes it much easier for AI to read, understand, and build. Beefree SDK's full JSON is complex and feature-rich, making it difficult to train AI on.
For email sequences, the Simple Schema remains the same for each email, but we generate three different emails with specific purposes and contexts.
Email Types and Contexts
The following code snippet shows how to define different email types with specific contexts for sequence generation.
Template Structure (Same for all emails)
The following code snippet shows the template structure for simple JSON that applies to all emails in the sequence.
Supported Module Types
Simple Schema supports the following module types:
title- Email titles and headingsparagraph- Text contentbutton- Call-to-action buttonsimage- Images and graphicsdivider- Visual separatorshtml- Custom HTML contentlist- Bulleted or numbered listsmenu- Menusicons- Social media and other icons
2. Sequential Anthropic API Integration
This section discusses how to structure and make sequential API calls to Anthropic for generating multiple emails with different contexts.
Sequential Email Creation Function
The following code snippet shows how to create emails sequentially with different contexts for each email type.
API Call Structure
The following code snippet shows an example API call to Anthropic for sequential email generation.
3. Frontend Integration for Sequences
This section discusses the Frontend integration and how to capture an end user's email description prompt, manage progressive UI updates, and handle navigation between multiple emails.
Sequence Initialization
The following code snippet shows how to initialize the email sequence creation process.
Capturing User Input
Progressive UI Updates
The following code snippet shows how to update the UI progressively as each email is created.
4. Response Parsing for Multiple Emails
This section includes two important topics. The first is how to parse the response from Anthropic to only get the simple JSON and pass it to the /simple-to-full-json endpoint. The second is how to configure a second API call in the event the first one fails. Beefree SDK provides comprehensive feedback in the error message for a failed /simple-to-full-json API call. By applying this comprehensive feedback in a second API, the AI model being used can typically return a valid simple JSON ready for conversion to full JSON.
Sequential Parsing Logic
The following code snippet shows how to parse responses for multiple emails in sequence.
Error Correction for Sequences
5. Beefree SDK Integration for Sequences
This section discusses the Beefree SDK integration for managing multiple emails. Beefree SDK provides the editing environment to load the full JSON into once it is created. Once it is loaded within the editor, the end user can begin customizing their AI-generated email design and navigate between different emails in the sequence.
Multiple Template Storage
The following code snippet shows how to store multiple emails with specific keys for navigation.
Opening Specific Emails in Builder
Converting Simple to Full JSON
Persistent Email Navigation
The following code snippet shows how to manage navigation between emails and persist state.
Enhanced Builder with Navigation
Complete Implementation
This section includes the code for both APIs together (Anthropic API call and /simple-to-full-json API call), and the dependencies they require.
Proxy Server (proxy-server.js)
Email Sequence Strategy
Welcome Email
Purpose: First touchpoint with new subscribers
Context: Outstanding welcome email following email marketing best practices
Key Elements:
Warm welcome message
Set expectations
Build excitement
Clear next steps
Onboarding Email
Purpose: Guide users through getting started
Context: Amazing onboarding email following email marketing and instructional best practices
Key Elements:
Step-by-step instructions
Helpful resources
User activation tips
Support information
Upgrade Email
Purpose: Encourage subscription upgrades
Context: Upgrade your subscription for more perks email following email marketing best practices and outlining the top three perks for upgrading
Key Elements:
Top three benefits
Clear value proposition
Strong call-to-action
Social proof
Customization Tips
This section list a few customization tips you can apply to the code in your own environment.
Email Types: Modify the
emailTypesarray to create different sequences (e.g., product launch, seasonal campaigns)Context Customization: Adjust the context prompts for each email type based on your specific needs
Sequential Logic: Add delays between email generation or implement parallel processing
Progress Tracking: Add more detailed progress indicators for each email
Template Validation: Implement sequence-specific validation rules
User Experience: Add preview functionality for the entire sequence
Troubleshooting
If you encounter any errors, try troubleshooting the following:
Sequential Errors: Handle failures in individual email generation without stopping the entire sequence
Storage Management: Implement cleanup for old sequences and manage localStorage limits
Navigation Issues: Ensure proper state management when switching between emails
Performance: Optimize for multiple API calls and large template storage
This recipe provides a complete foundation for building AI-powered email sequence creation systems with Beefree SDK and Anthropic's Messages API and Claude Sonnet 4 model.
Last updated
Was this helpful?

