Scott Reed
Mar 30, 2026
  50
(2 votes)

Supercharging Optimizely Forms: Introducing Dynamic Email Routing & Conditional Submissions

Supercharging Optimizely Forms: Introducing Dynamic Email Routing & Conditional Submissions

Optimizely Forms is a powerhouse for gathering user data, but as implementations grow in complexity, we often run into a common limitation with the built-in "Send email after form submission" actor: it's a bit static.

In a typical enterprise scenario, you don't just want one email going to one place. You might need to route a lead to the "Sales" team if they select a specific department, or perhaps you only want an email sent if the user ticks a "Request Callback" box.

To solve this, I’ve released an open-source package: ScottReed.Optimizely.Forms.DynamicEmailRouting. It’s a custom post-submission actor for CMS 12 that brings dynamic routing and complex conditional logic directly into the Forms UI.

The Problem: The "One-Size-Fits-All" Email

The default email actor is great for simple notifications. However, once you need logic like "If Department is 'Support', send to support@company.com" or "Only send this internal alert if 'Priority' is 'Critical'", you're usually forced to write custom code for every specific form or clutter the CMS with multiple overlapping actors.

The Solution: Dynamic Email Routing

This package extends the core functionality of the built-in email actor but adds two powerful layers: Email Routing and Conditional Logic.

1. Dynamic Email Routing

Instead of a single hardcoded "To" address, you can now define a mapping table. You select a form field, define a value to match, and specify the recipient. If no match is found, it gracefully falls back to the primary "To" address.

2. Conditional Logic (AND/OR)

Sometimes you don't want an email sent at all unless specific criteria are met. The actor allows you to add multiple conditions using "is" and "is not" operators. You can toggle between "Match ALL" (AND) or "Match ANY" (OR) logic.

Technical Implementation: Under the Hood

For the developers curious about how this is built, the package leverages several Optimizely extension points to ensure a "native" feel.

The Actor & Model

The core logic resides in DynamicEmailRoutingActor, which inherits from SendEmailAfterSubmissionActor. This is crucial because it allows us to reuse the existing EmailTemplateActorModel features—like the rich text editor, the "Insert Placeholder" dropdown, and the standard From/Subject fields—without reinventing the wheel.

The UI (Dojo & Protected Modules)

To provide a seamless editor experience, the package uses the Protected Module pattern. On build, the client-side resources (Dojo editors and language files) are zipped into a protected module folder.

I’ve implemented three custom Dojo editors:

  1. EmailRoutingEditor.js: Handles the dynamic table for routing.

  2. ConditionMatchEditor.js: A simple dropdown for logic selection.

  3. ConditionsEditor.js: Manages the conditional rules.

Localization

All labels and the actor name are localized via XML files embedded within the module, ensuring it fits perfectly into the Optimizely UI language settings.

Getting Started

Installation is a standard NuGet affair. Because it uses an IConfigurableModule for auto-registration, there's zero configuration required in your Startup.cs.

Install via NuGet:

https://nuget.optimizely.com/packages/scottreed.optimizely.forms.dynamicemailrouting/ 

dotnet add package ScottReed.Optimizely.Forms.DynamicEmailRouting

Configuration:

  1. Ensure your SMTP is configured in appsettings.json (the actor uses the standard Optimizely SMTP client).

  2. In the CMS, add the Dynamic email routing actor to your Form Container.

  3. Define your routes and conditions.

[Image Placeholder: Selecting the Dynamic Email Routing actor in the Form Settings tab]

Extensibility

The project is built with extensibility in mind. If you need more complex operators (like "contains" or "starts with"), you can easily extend the EvaluateConditions logic in the actor or contribute to the repository!

Wrap Up

By moving this logic into the CMS UI, we empower editors to manage complex workflows themselves without needing a deployment for every routing change.

You can find the full source code, documentation, and a test Alloy site on GitHub: 👉 scottreed/Optimizely-Dynamic-Form-Submission

I’d love to hear your feedback or see your PRs!

Mar 30, 2026

Comments

Please login to comment.
Latest blogs
Prove what your experimentation program is worth with Holdouts

Running experiments is one thing. Knowing whether your experimentation program is moving the business forward?  That's  the harder question.   Most...

Sarah Ager | Mar 30, 2026

How CMS Implementations Need to Change for GEO and AEO

Search is changing. AI systems are increasingly the first point of contact between your content and your audience, and they don't behave like...

Andy Blyth | Mar 27, 2026 |

VirtualText 2.0.0 beta for Optimizely CMS 13 previews

DavidHome.Optimizely.VirtualText   2.0.0 has been released as beta for Optimizely CMS 13 previews. This is a major technical release. The focus is...

David Drouin-Prince | Mar 27, 2026 |

Technical Q&A for CMS 13

This blog post explains what to expect when planning to upgrade to Optimizely CMS 13. It answers common technical questions about what’s involved i...

Luc Gosso (MVP) | Mar 26, 2026 |

Custom Property Editors in Optimizely CMS 13

When the world  first saw how to create custom editors for Optimizely CMS  back in 2012, it was a game-changer for Javascript developers. For the...

Grzegorz Wiecheć | Mar 26, 2026