Kajabi Engineering

Harnessing AI for Email Analytics using Snowflakes Cortex LLM

Our Data Platform team deals with an intricate web of data sources, managing batch and event data across numerous systems. The aim is to furnish our business users and customers with powerful analytics tools, giving them insights that can propel their businesses forward. It's a world of endless data streams, and our mission is to channel these into meaningful narratives for growth and success.

Introduction to Enhanced Email Analytics with AI

Kajabi is a platform designed as a one-stop shop for creators who want to build and run their online business. The reality for many of our users is that they're experts in their subject matter — whether fitness, photography, or finance — but often not business experts. They suddenly find themselves needing to know a whole bunch of other things like: marketing, advertising, and particularly, email campaigns.

These aren't just side tasks; they are essential parts of running a successful online business. They are also time-consuming and outside many creators' wheelhouses. We make these parts easier, taking some of that burden off their shoulders. Creators should be able to focus on their passion — their content and community — and less on figuring out the best subject line for an email. We often ask ourselves questions like:

  • How can we help our creators with email marketing?
  • How can we make it less of a shot in the dark and more of a science?

It is a struggle to understand what makes their marketing emails work. It requires looking beyond simple metrics like opens and clicks to understand the underlying factors that drive engagement and conversions.

To support this, we've initiated an extensive analysis using AI to better understand the emails being sent via Kajabi. We’re not just counting open rates; we're analyzing the email’s structure, tone, voice, and sentiment. We also consider the context. Does it include a call to action? If so, how many, and where are they placed? What's the email’s overall purpose or theme? What elements evoke a sense of urgency?

This information, derived from our AI's analysis, is incredibly valuable. It allows our analytics team to create a sophisticated model that understands what a "good" email looks like based on historical performance data. This isn't about creating a one-size-fits-all approach; it's about personalization. It's about providing specific advice for specific situations.

And here's the really exciting part: as our creators are crafting their marketing emails, our AI models can step in to assist. Picture an AI that doesn’t just analyze but also suggests, refines, and optimizes. It tailors content to match the best-performing emails within a given industry, for a particular business size, or for a certain audience demographic.

We're going to explore how these capabilities are not just conceptual but are actively being integrated into Kajabi to enhance the user experience. We’ll see how this translates into practical, everyday tools that our creators can use to not only write emails but also to continuously learn and improve their marketing strategies.

Harnessing Snowflake Cortex LLM Functions for Deep Email Analysis

Our initial solution was very manual and built outside of Snowflake. Our teams invested significant time and effort, but scaling it to handle millions of emails was like hitting a wall. We were faced with severe throttling issues and a complex, cumbersome process of data transfer. From formatting emails for our Python application to handling retries for failed attempts, every step was a challenge. It was a traditional setup, but one that was ‘just OK’ after months of laborious effort and numerous project check-ins.

Transitioning to Snowflake Cortex LLM functions marked a pivotal shift in our approach. Cortex brought the analysis into the database, eliminating the cumbersome data extraction and transformation steps. With a few lines of SQL, we could perform nuanced analysis, asking intricate questions of our dataset that previously would have required intricate scripting and error handling.

What previously stretched out over several months of tweaking and fine-tuning was now accomplished in a few hours, a testament to the power and simplicity that Snowflake’s Cortex functions brought to our project. This efficiency didn't just speed up the process; it fundamentally changed how we could think about and utilize our data for actionable insights.

A Deep Dive into Cortex LLM Functions in Action

Let’s dive into how we now apply Snowflake Cortex LLM functions to our email analysis process. Below is a snippet of our dbt model that illustrates the marriage of SQL with AI.

1{{ config(
2    materialized='incremental',
3    full_refresh = false,
4    incremental_strategy = 'append',
5    unique_key='id',
6    tags=["exclude_from_ci", "exclude_from_build_prod"]
7) }}
8
9select
10    id,
11    email_type,
12    original_email_body,
13    snowflake.ml.complete('llama2-70b-chat',
14    CONCAT(
15        '\n\nHuman: we need to analyze the text of the marketing e-mail in <email></email> tag.\n<email>\n',
16        original_email_body,
17        '\n</email>
18
19        Provide a valid JSON response using the following format, no preamble or postamble:
20        {
21            "sentiment": string,
22            "voice": string,
23            "tone": string,
24            "urgency": string,
25            "topic": string,
26            "hasCallToAction": boolean,
27            "callToActionCount": number,
28            "callToActionList": string[],
29            "mainCallToActionPlacement": string
30        }
31
32        if you do not know set the parameter to NONE
33
34        Return ONLY the valid json; NOTHING ELSE, no commentary
35
36        Assistant:'
37    ) as metadata
38from {{ref('broadcast_emails')}}
39{% if is_incremental() %}
40    and id not in (select id from {{ this }})
41{% endif %}
42limit 20000

First we have  the configuration part of a dbt model, which sets the stage for how we handle the data incrementally. This means as new data comes in, we're only processing what's necessary, which keeps our operations efficient. Since these LLM functions are billed separately from the warehouses we also made sure to exclude these jobs from running in our CI testing and hourly production job builds so we could better keep within the imposed daily limits.

We use the COMPLETE function from Snowflake, combined with a standard SQL CONCAT to generate a prompt that instructs the AI on how to analyze our emails. The AI takes each email's body and returns structured JSON with the analyzed attributes such as sentiment, voice, tone, urgency, and topics.

The real beauty here is the simplicity; this is just a SQL query. There are no complex Python scripts or external processing. We're conducting sophisticated AI analysis right within the Snowflake environment, and it's this kind of streamlining that's become a real game-changer for us.

We also face the challenge of bringing together the global tapestry of our customer base, many of whom communicate in languages other than English. To truly understand and compare the effectiveness of their marketing emails, we needed a uniform language base. That’s where Snowflake's Translate function came in.

1{{ config(
2    materialized='incremental',
3    full_refresh = false,
4    incremental_strategy = 'append',
5    unique_key='id',
6    tags=["exclude_from_ci", "exclude_from_build_prod"]
7) }}
8
9select
10    id,
11    email_type,
12    original_email_body,
13    language as original_language,
14    SNOWFLAKE.ML.TRANSLATE(original_email_body, language, 'en') as translated
15from {{ref('broadcast_emails_language_detected')}}
16where language in ('de', 'es', 'fr', 'it', 'ja', 'ko', 'ru', 'pl', 'pt', 'sv')
17{% if is_incremental() %}
18    and id not in (select id from {{ this }})
19{% endif %}
20limit 100000

Above is another piece of the code from our dbt model, which translates the content of emails from various languages into English. This function is crucial because it handles high volumes with ease, allowing us to translate and then analyze a vast amount of emails swiftly. We set the SQL query to filter emails in languages like German, Spanish, French, and several others, then used the TRANSLATE function to convert them to English.

By incorporating this step we level the playing field, analyzing emails from our customers with the same lens regardless of the original language. This didn’t just add a layer of consistency to our analysis; it also significantly expanded our understanding of global communication patterns in email marketing.

This translation step proved to be both efficient and powerful, demonstrating how a simple SQL function can have a profound impact on our analytics capabilities, making our AI-driven insights truly international.

What’s Next?

Kajabi's future with AI is not just about technology; it's about transformative experiences for our creators. We envision AI as a strategic partner that can offer real-time, actionable business advice, transcending traditional email optimization. It's about understanding our creators on a deeper level, tailoring their experiences, and helping them make data-enhanced decisions for their businesses.

We plan to scale this technology to cover new aspects of the creator journey. Imagine AI-powered personal assistants that understand the nuances of our creators' businesses, offer personalized marketing strategies, and help optimize their content for different platforms and audiences. We are using AI to build a bridge to help our creators cross the chasm from where they are to where they aspire to be, making Kajabi an ecosystem where every entrepreneur has a personalized roadmap to success powered by sophisticated AI insights.

Most importantly, as we harness these AI capabilities, we intend to ensure that our platform remains as accessible and user-friendly as ever. This means integrating AI in a way that feels seamless and natural, improving the Kajabi experience without adding complexity for our users. We're not just enhancing emails; we're creating a holistic environment where every interaction, every piece of content, and every strategic decision can be optimized. Our goal is clear: to empower our creators with cutting-edge tools that are invisible in their simplicity yet powerful in their impact.

Similar Posts
No items found.