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 seven action types, split into five 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
create_taskAutomations page (/automations)Task creation rules are general-purpose, similar to tag rules
send_notificationAutomations page (/automations)Internal alerts are general-purpose operational rules

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


Task Actions

Task actions automatically create to-do items in response to triggers. These rules are managed on the central Automations page (/automations).

Create Task

action_typecreate_task
action_idA generated UUID (ensures uniqueness — allows multiple create_task rules per trigger)
action_configInline JSONB configuration (see below)
BehaviorCreates a new task row linked to the triggering contact, with title, description, assignee, and a calculated due date from the action config.

Unlike tag and campaign actions — which point action_id at a pre-existing entity (a tag or campaign) — the create_task action has no pre-existing entity to reference. The task doesn’t exist until the automation fires.

Inline action_config

When action_type = 'create_task', the action_config JSONB column stores the task blueprint:

{
  "title": "Follow up with new lead",
  "description": "Review form submission and send intro email",
  "assigned_to": "user-uuid-or-null",
  "due_offset_hours": 48
}
FieldTypeDescription
titlestringThe task title (defaults to "Follow up" if not set)
descriptionstringOptional task description
assigned_touuid | nullThe workspace member to assign the task to
due_offset_hoursnumberDue date offset in hours from trigger time (e.g. 48 = 2 days from now)

Why inline config instead of task templates? A task template table would require its own CRUD surface, RLS policies, and navigation entry — all for something used rarely. Inline action_config on the automation rule itself keeps the design simple with zero new tables. Users who need the same task config on multiple rules can manually recreate the rule with the same settings.

Contact and Deal Linking

When the automation fires:

  • Contact is always auto-linked from the trigger’s contactId (every trigger provides a contact context).
  • Deal is auto-linked from the trigger context when available (e.g. deal_stage_changed triggers).
  • Due date is calculated as trigger_time + due_offset_hours.

UI Form

When a user selects "Create Task" as the action type on the Automations page, the standard entity picker is replaced with an inline form:

FieldInputDescription
Task TitleText inputRequired — the title of the task to create
DescriptionText inputOptional details
Assign ToDropdown (workspace members)Who gets assigned
Due InNumber input + "hours after trigger"When the task is due

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
create_taskTask title from action_config.title
send_agreementTemplate title from the agreement_templates table
send_notificationRecipient names from workspace member profiles

Agreement Actions

Agreement actions dispatch digital agreements to a contact for signing.

Send Agreement

action_typesend_agreement
action_idThe UUID of the agreement template
action_config{"template_id": "uuid"}
BehaviorDispatches the specified agreement template to the contact via email with a tokenized signing link.

Dedup Behavior

The dispatch service applies the same dedup logic as manual sending:

Existing StateResult
Signed at current versionSilently skipped (no email, no new record)
Signed at older versionNew pending agreement created for the current version
PendingExisting token resent (acts as a reminder)
No existing recordNew pending agreement created

UI Form

When a user selects "Send Agreement" as the action type on the Automations page, the standard entity picker is replaced with a template dropdown listing all active agreement templates. If no active templates exist, italic helper text reads: "No active templates. Create one in Settings → Agreement Templates."

See Agreements for full documentation on template management and the signing flow.


Notification Actions

Notification actions send internal email alerts to workspace members (and optionally external recipients) when a trigger fires. These are managed on the central Automations page.

Send Notification

action_typesend_notification
action_idA generated UUID (same pattern as create_task)
action_configInline JSONB configuration (see below)
BehaviorSends an internal notification email to all configured recipients with contact details and trigger context.

Inline action_config

When action_type = 'send_notification', the action_config JSONB column stores the recipient configuration:

{
  "member_ids": ["user-uuid-1", "user-uuid-2"],
  "external_emails": ["partner@example.com"]
}
FieldTypeDescription
member_idsuuid[]Workspace members to notify (resolved to their email addresses at send time)
external_emailsstring[]Additional email addresses outside the workspace

At least one recipient (member or external) is required.

What the Email Contains

Notification emails automatically include:

  • Contact details — The name and email of the contact who triggered the automation.
  • Trigger context — Which trigger fired (e.g. "Form submitted: Request a Demo").
  • Deal enrichment — When triggered by a deal event (deal_stage_changed or deal_status_changed), the email also includes the deal name and deal value (formatted as currency).

UI Form

When a user selects "Send Internal Notification" as the action type on the Automations page:

FieldInputDescription
Notify MembersMember picker (multi-select)Select one or more workspace members
External EmailsText input with chip displayType an email address and press Enter to add it