Automations
Actions

Actions

An action is what Gordon CRM does automatically when a matching trigger fires. Each action targets a specific entity via its action_id — either a tag or a campaign.

Gordon CRM supports four action types, split into two categories.


Tag Actions

Tag actions modify a contact's tags. These are the most common automation actions and appear on the central Automations page (/automations).

Add Tag

action_typeadd_tag
action_idThe UUID of the tag to apply
BehaviorAdds the specified tag to the contact. Uses UPSERT with ON CONFLICT … DO NOTHING for idempotency — if the contact already has the tag, the operation is silently skipped.

After a tag is successfully added, the engine fires a cascading tag_applied trigger for the newly added tag. This enables chaining — for example, adding tag A can trigger a rule that enrolls the contact in a campaign.

Form submitted
  → Action: Add "VIP" tag
     → Cascading trigger: "VIP" tag applied
        → Action: Enroll in "VIP Welcome" campaign

Important: Cascading tag triggers increment an internal depth counter. If the depth exceeds 3, the chain is terminated to prevent infinite loops. See Loop Protection.


Remove Tag

action_typeremove_tag
action_idThe UUID of the tag to remove
BehaviorRemoves the specified tag from the contact. If the tag was not applied, the operation is silently skipped.

After a tag is successfully removed (confirmed by checking the return value), the engine fires a cascading tag_removed trigger. This allows exit workflows — for example, removing a "Member" tag can unenroll a contact from member-only campaigns.


Campaign Actions

Campaign actions manage a contact's enrollment in drip sequence campaigns. These rules are managed on each Campaign detail page (/campaigns/[id]) and are excluded from the central Automations page.

Enroll in Campaign

action_typeenroll_campaign
action_idThe UUID of the campaign
BehaviorCreates a campaign_enrollments row for the contact with status: active. Uses the campaign engine to calculate the first eligible step and its scheduled next_action_at timestamp.

The enrollment process includes multiple safety checks:

  1. Active enrollment check — If the contact already has an active or processing enrollment in the same campaign, the action is skipped entirely.
  2. Trigger event dedup — If a triggerEventId is provided (e.g., from an event registration), the engine checks for a prior completed enrollment with the same trigger event ID. This prevents webhook retries from re-enrolling contacts.
  3. Campaign status check — The campaign itself must be in active status. Draft or paused campaigns will not accept new enrollments.
  4. Step calculation — The campaign engine's calculateNextCampaignStep function determines when the first email should be sent based on delay offsets and event dates. If all steps are in the past (late enrollee), the enrollment is immediately marked as completed.

Remove from Campaign

action_typeremove_campaign
action_idThe UUID of the campaign
BehaviorSets the contact's active enrollment to status: cancelled and records a cancelled_at timestamp. Only cancels enrollments with active or processing status.

This is typically used as part of an exit criteria workflow on the campaign detail page — for example, "When the contact is tagged as 'Unresponsive' → remove from this campaign."


Where Actions Are Managed

Action TypeManaged OnWhy
add_tag, remove_tagAutomations page (/automations)General-purpose rules, not tied to a specific campaign
enroll_campaign, remove_campaignCampaign detail page (/campaigns/[id])Tightly coupled to campaign lifecycle; entry/exit criteria belong with the campaign

This split keeps the UI focused — marketers manage campaign enrollment rules alongside the campaign itself, while system-level tag automations live in a central hub.


Action Entity Resolution

When displaying rules in the UI, the engine resolves action_id values to human-readable names:

Action TypeResolution Strategy
add_tag / remove_tagTag name from the tags table
enroll_campaign / remove_campaignCampaign name from the campaigns table