Scott Reed
Mar 30, 2026
  427
(3 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

Jeremy Brown
Jeremy Brown Apr 9, 2026 02:12 PM

Nice one Scott - the timing of the release of your package was almost perfect 👍

Scott Reed
Scott Reed Apr 9, 2026 03:34 PM

Let me know if there's any issues. FYI I have a few new features coming shortly

  • Condition control for the notifications
  • More conditions
  • Dropdowns instead of text when value is a selection

Should come shortly!

Scott Reed
Scott Reed Apr 13, 2026 02:24 PM

All these features are now released on to the 1.1.0. version on the nuget feed. Also a checkbox on the conditions allowing a master toggle has been added

Please login to comment.
Latest blogs
Optimizely migration from CMS 12 to CMS 13

Upgrading from Optimizely CMS 12 to CMS 13 alongside moving the runtime from .NET 8.0 to .NET 10.0 is far more than a routine version upgrade. It i...

Sanjay Kumar | Apr 24, 2026

Optimizely CMS 13 host(s) management

One of the features I found most impressive is the way Optimizely CMS 13 handles hosts with clear definition and intent. It may sound low level...

Harish Yadav | Apr 23, 2026

Building Opal tools on Optimizely Connect Platform: a Mailchimp walkthrough

About the Mailchimp Opal Tool The  Mailchimp Opal Tool  is an Optimizely Connect Platform app that brings Mailchimp audience operations directly in...

Sanjay Kumar | Apr 22, 2026