Skip to main content

Automations

Automations allow you to build powerful, event-driven workflows that respond to billing events, customer actions, and scheduled triggers. From sending dunning emails to syncing data with external systems, automations help you scale your operations without manual intervention.

What Are Automations?

Automations are configurable workflows that:
  • Trigger based on events or schedules
  • Evaluate conditions to determine if actions should run
  • Execute actions like sending emails, updating records, or calling APIs
  • Branch and loop for complex logic

Key Concepts

Triggers

Triggers define when an automation runs:
TypeDescription
EventRuns when a specific event occurs
ScheduleRuns on a time-based schedule
ManualRuns when triggered via API

Conditions

Conditions filter whether the automation should continue:
IF invoice.amount > 1000
AND customer.segment = "enterprise"
THEN continue
ELSE skip

Actions

Actions are the operations performed:
  • Send email
  • Send SMS
  • Create task
  • Update record
  • Call webhook
  • Retry payment

Steps

Steps are the building blocks combined into a workflow:
  • Action steps - Execute a single action
  • Condition steps - Branch based on logic
  • Delay steps - Wait before continuing
  • Loop steps - Iterate over collections

Supported Triggers

Event Triggers

EventDescription
invoice.issuedInvoice was issued
invoice.paidInvoice was paid
invoice.overdueInvoice became overdue
payment.failedPayment attempt failed
payment.succeededPayment succeeded
subscription.activatedSubscription became active
subscription.canceledSubscription was canceled
subscription.ending_soonSubscription ending within X days
customer.createdNew customer created
credits.depletedCredit balance reached zero
usage.threshold_exceededUsage exceeded threshold

Schedule Triggers

TypeExample
IntervalEvery 24 hours
Cron0 9 * * 1 (Mondays at 9 AM)
CalendarFirst day of month

Available Actions

Communication

ActionDescription
send_emailSend templated email
send_smsSend SMS message
send_slackPost to Slack channel
send_webhookCall external webhook

Billing

ActionDescription
retry_paymentRetry failed payment
void_invoiceVoid an invoice
create_credit_noteGenerate credit note
apply_creditsApply credits to invoice

Records

ActionDescription
update_customerUpdate customer fields
add_tagAdd tag to customer
create_taskCreate internal task
sync_to_crmSync data to CRM

Workflow

ActionDescription
delayWait for duration
branchConditional branching
loopIterate over items
stopEnd workflow

Creating Automations via Dashboard

Step 1: Create the Automation

  1. Navigate to Settings → Automations
  2. Click Create Automation
  3. Choose how to start:
    • From Template: Select a pre-built template (Dunning, Welcome Series, etc.)
    • From Scratch: Build a custom automation

Step 2: Configure the Trigger

  1. Select Trigger Type:
    • Event: Runs when something happens (e.g., payment failed)
    • Schedule: Runs on a schedule (daily, weekly, etc.)
  2. Choose the specific event or schedule
  3. Click Next

Step 3: Add Conditions (Optional)

Filter when the automation should run:
  1. Click Add Condition
  2. Build your condition:
    • Field: invoice.amount, customer.segment, etc.
    • Operator: equals, greater than, contains
    • Value: The value to compare
  3. Combine multiple conditions with AND/OR
  4. Click Next

Step 4: Add Actions

  1. Click Add Action
  2. Choose action type:
    • Send Email: Select template and recipients
    • Send SMS: Configure message
    • Retry Payment: Attempt payment again
    • Update Record: Change customer/subscription fields
    • Wait: Delay before next action
  3. Configure action settings
  4. Add more actions as needed

Step 5: Test and Activate

  1. Click Test Automation to run with sample data
  2. Review the test results
  3. Click Activate when ready

Example: Payment Dunning Workflow

  1. Create automation with trigger: Payment Failed
  2. Add action: Send email (template: “Payment Failed - Gentle Reminder”)
  3. Add wait: 3 days
  4. Add condition: If invoice still unpaid
  5. Add action: Retry payment
  6. Add action: Send email (template: “Payment Failed - Urgent”)
  7. Add wait: 7 days
  8. Add action: Final notice email
  9. Activate

Managing Automations

View Executions

  1. Navigate to Automations → [Automation Name]
  2. Click Executions tab
  3. See each run with status, trigger details, and results
  4. Click any execution to see step-by-step log

Pause/Resume

  1. Find the automation in the list
  2. Click the toggle to pause or resume
  3. Paused automations won’t trigger until resumed

Version History

  1. Open the automation
  2. Click Versions
  3. View previous versions
  4. Restore if needed

Automation Templates

Start with pre-built templates in the dashboard:
TemplateDescription
Payment DunningMulti-step sequence for failed payments
Welcome SeriesOnboarding emails for new customers
Renewal ReminderNotify before subscription renewal
Usage AlertAlert when usage exceeds threshold
Win-back CampaignRe-engage canceled customers

Quick Start (API)

Example: Payment Failed Dunning

name: Payment Failed - Dunning Email
trigger:
  type: event
  event: payment.failed

steps:
  - type: condition
    if: "{{trigger.failureCount}} == 1"
    then:
      - type: action
        action: send_email
        template: payment_failed_first
        to: "{{trigger.customer.email}}"

  - type: delay
    duration: "3d"

  - type: condition
    if: "{{invoice.status}} == 'unpaid'"
    then:
      - type: action
        action: retry_payment

Template Variables

Access data from the trigger context using template syntax:

Invoice Variables

{{invoice.id}}
{{invoice.total}}
{{invoice.currency}}
{{invoice.status}}
{{invoice.dueDate}}
{{invoice.customer.name}}
{{invoice.customer.email}}

Payment Variables

{{payment.id}}
{{payment.amount}}
{{payment.status}}
{{payment.failureReason}}
{{payment.failureCount}}

Customer Variables

{{customer.id}}
{{customer.name}}
{{customer.email}}
{{customer.segment}}
{{customer.createdAt}}

Automation Templates

Start with pre-built templates:

Payment Dunning

Multi-step dunning sequence for failed payments.

Welcome Series

Onboarding email sequence for new customers.

Renewal Reminder

Notify customers before subscription renewal.

Usage Alert

Alert when usage exceeds threshold.

Versioning

Automations support versioning for safe updates:
Version StateDescription
draftWork in progress, not active
activeCurrently running version
inactivePreviously active, now disabled

Version Workflow


Execution Tracking

View Executions

Monitor automation runs at Automations > Executions:
  • Execution status (success, failed, running)
  • Trigger details
  • Step-by-step execution log
  • Error messages

Execution API

curl https://api.alguna.io/automations/auto_123/executions \
  -H "Authorization: Bearer YOUR_API_KEY"
Response:
{
  "executions": [
    {
      "id": "exec_456",
      "status": "completed",
      "triggeredBy": "invoice.paid",
      "triggeredAt": "2024-01-20T10:00:00Z",
      "completedAt": "2024-01-20T10:00:05Z",
      "stepsExecuted": 3
    }
  ]
}

Error Handling

Retry Configuration

Configure automatic retries for failed steps:
{
  "errorHandling": {
    "retries": 3,
    "retryDelay": "5m",
    "backoffMultiplier": 2
  }
}

Fallback Actions

Define fallback actions when steps fail:
steps:
  - type: action
    action: send_email
    onError:
      - type: action
        action: create_task
        assignee: "{{trigger.accountOwner}}"
        message: "Email failed to send"

Best Practices

Start Simple

Begin with single-step automations, then add complexity.

Test Thoroughly

Use draft versions and test data before activating.

Monitor Executions

Regularly review execution logs for failures.

Use Templates

Start from templates and customize as needed.

Use Cases

Dunning Management

Automate payment recovery:
  1. Send email on first failure
  2. Wait 3 days
  3. Send second email with payment link
  4. Wait 5 days
  5. Retry payment automatically
  6. Escalate to collections if still unpaid

Subscription Renewal

Notify customers before renewal:
  1. 30 days before: Send renewal reminder
  2. 7 days before: Send confirmation request
  3. On renewal: Send receipt

Usage Alerts

Monitor and alert on usage:
  1. Check usage threshold daily
  2. If exceeded: Send alert to customer
  3. If > 120%: Notify account manager

Next Steps