Automation Reference
Complete reference guide for building automations in Alguna. This page documents all available triggers, actions, step types, template syntax, and condition expressions.Trigger Types
Triggers define when an automation runs. Each trigger provides specific data that can be used in subsequent steps.Payment Failed
Fires when a payment attempt fails.| Property | Type | Description |
|---|---|---|
trigger_type | PaymentFailed | Trigger identifier |
invoice_id | string | The invoice that failed to collect |
payment_method_id | string | Payment method used |
failure_code | string | Reason for failure |
failure_message | string | Human-readable failure message |
attempt_number | integer | Which retry attempt (1, 2, 3…) |
Invoice Status Updated
Fires when an invoice status changes.| Property | Type | Description |
|---|---|---|
trigger_type | InvoiceStatusUpdated | Trigger identifier |
invoice_id | string | The invoice |
previous_status | string | Status before change |
new_status | string | Current status |
status_changed_at | timestamp | When the change occurred |
draft, issued, paid, void, past_due, uncollectible
Example trigger data:
Prepaid Usage Update
Fires when prepaid credit usage changes significantly.| Property | Type | Description |
|---|---|---|
trigger_type | PrepaidUsageUpdate | Trigger identifier |
wallet_id | string | The wallet affected |
previous_balance | decimal | Balance before update |
current_balance | decimal | Current balance |
usage_amount | decimal | Amount consumed |
threshold_crossed | boolean | If a threshold was crossed |
Subscription Sent for Signature
Fires when a subscription requires signature.| Property | Type | Description |
|---|---|---|
trigger_type | SubscriptionSentForSignature | Trigger identifier |
subscription_id | string | The subscription |
version_id | string | Version requiring signature |
sent_to | string | Email address |
sent_at | timestamp | When sent |
Credits Depleted
Fires when credit balance reaches zero or a threshold.| Property | Type | Description |
|---|---|---|
trigger_type | CreditsDepleted | Trigger identifier |
wallet_id | string | The wallet |
depleted_at | timestamp | When depleted |
last_grant_id | string | Most recent credit grant |
Subscription Status Updated
Fires when a subscription status changes.| Property | Type | Description |
|---|---|---|
trigger_type | SubscriptionStatusUpdated | Trigger identifier |
subscription_id | string | The subscription |
previous_status | string | Status before change |
new_status | string | Current status |
draft, pending, active, paused, canceled, expired
Example trigger data:
Action Types
Actions are the operations performed by your automation.Communication Actions
send_email
Send an email using a template.| Parameter | Type | Required | Description |
|---|---|---|---|
template_id | string | Yes | Email template to use |
to | string | Yes | Recipient email (supports templates) |
cc | string[] | No | CC recipients |
bcc | string[] | No | BCC recipients |
variables | object | No | Template variables |
send_invoice_reminder
Send a payment reminder for an invoice.| Parameter | Type | Required | Description |
|---|---|---|---|
invoice_id | string | Yes | Invoice to remind about |
reminder_type | string | No | gentle, firm, final |
send_invoice_reminders_bulk
Send reminders for multiple invoices.| Parameter | Type | Required | Description |
|---|---|---|---|
invoice_ids | string[] | Yes | Invoices to remind about |
reminder_type | string | No | Reminder severity level |
send_billing_info_request
Request updated billing information from customer.| Parameter | Type | Required | Description |
|---|---|---|---|
account_id | string | Yes | Customer account |
reason | string | No | Why info is needed |
share_customer_portal_link
Send customer portal access link.| Parameter | Type | Required | Description |
|---|---|---|---|
account_id | string | Yes | Customer account |
expires_in | string | No | Link expiration (e.g., 7d) |
send_subscription_signature_reminder
Remind customer to sign a pending subscription.| Parameter | Type | Required | Description |
|---|---|---|---|
subscription_id | string | Yes | Subscription awaiting signature |
version_id | string | No | Specific version |
send_subscriptions_autorenewal_notification_bulk
Notify customers about upcoming auto-renewals.| Parameter | Type | Required | Description |
|---|---|---|---|
subscription_ids | string[] | Yes | Subscriptions renewing |
days_before | integer | No | Days before renewal |
Data Retrieval Actions
get_invoice
Retrieve a single invoice.| Parameter | Type | Required | Description |
|---|---|---|---|
invoice_id | string | Yes | Invoice to retrieve |
get_invoices
Retrieve multiple invoices with filters.| Parameter | Type | Required | Description |
|---|---|---|---|
account_id | string | No | Filter by account |
status | string[] | No | Filter by status |
due_before | string | No | Filter by due date |
limit | integer | No | Max results |
get_subscription
Retrieve a single subscription.| Parameter | Type | Required | Description |
|---|---|---|---|
subscription_id | string | Yes | Subscription to retrieve |
get_subscriptions
Retrieve multiple subscriptions with filters.| Parameter | Type | Required | Description |
|---|---|---|---|
account_id | string | No | Filter by account |
status | string[] | No | Filter by status |
renews_before | string | No | Filter by renewal date |
Billing Actions
retry_invoice_payment
Retry payment collection for an invoice.| Parameter | Type | Required | Description |
|---|---|---|---|
invoice_id | string | Yes | Invoice to retry |
payment_method_id | string | No | Specific payment method |
cancel_subscription
Cancel a subscription.| Parameter | Type | Required | Description |
|---|---|---|---|
subscription_id | string | Yes | Subscription to cancel |
cancel_at | string | No | immediate or end_of_period |
reason | string | No | Cancellation reason |
Integration Actions
send_webhook
Send data to an external webhook.| Parameter | Type | Required | Description |
|---|---|---|---|
url | string | Yes | Webhook endpoint |
method | string | No | HTTP method (default: POST) |
headers | object | No | Custom headers |
body | object | Yes | Request payload |
Step Types
Automations are composed of steps that execute in sequence.Action Step
Execute a single action.Condition Step
Branch based on a condition.Delay Step
Wait before continuing.30m (minutes), 24h (hours), 7d (days)
ForEach Step
Iterate over a collection.DoUntil Step
Repeat until a condition is met.Template Syntax
Use templates to reference dynamic data in your automation.Basic Syntax
Access data using double curly braces:Accessing Trigger Data
Accessing Step Outputs
Reference outputs from previous steps:Built-in Variables
| Variable | Description |
|---|---|
{{now}} | Current timestamp |
{{today}} | Current date |
{{iteration}} | Current loop iteration (in ForEach/DoUntil) |
{{secrets.KEY}} | Access stored secrets |
Filters
Transform values with filters:Condition Syntax
Conditions use the Expr expression language.Comparison Operators
| Operator | Description | Example |
|---|---|---|
== | Equal | trigger.status == 'paid' |
!= | Not equal | trigger.status != 'draft' |
> | Greater than | trigger.amount > 100 |
>= | Greater or equal | trigger.attempt_number >= 3 |
< | Less than | trigger.balance < 50 |
<= | Less or equal | trigger.days_overdue <= 30 |
Logical Operators
| Operator | Description | Example |
|---|---|---|
&& | AND | trigger.status == 'past_due' && trigger.amount > 100 |
|| | OR | trigger.status == 'paid' || trigger.status == 'void' |
! | NOT | !trigger.is_test |
String Operations
Array Operations
Null Checks
Complete Examples
Dunning Automation
Progressive payment failure handling:Renewal Notification Automation
Notify customers before renewal:Low Credit Balance Alert
Alert when credits are running low:Error Handling
Retry Configuration
Configure retry behavior for actions:On Error Handling
Define behavior when a step fails:stop- Halt automationcontinue- Skip and continuegoto- Jump to specific step
Best Practices
Use Descriptive IDs
Name steps clearly:
send_gentle_reminder not step_1.Test with Small Batches
Test automations with filtered triggers before going live.
Add Delays Thoughtfully
Avoid overwhelming customers with rapid-fire communications.
Log External Calls
Use webhooks to log automation events for debugging.