Reten Docs
Activities Guide

Activity Injection

How Reten dispatches activities to external providers via cron scheduling and pluggable dispatchers.

Reten handles activity dispatch automatically — you configure a provider and channel, and the platform sends activities to your system on a regular schedule.

How Dispatch Works

When activities are created with READY status, Reten's dispatch system picks them up and sends them to the configured external provider:

  1. A cron job runs every 30 seconds, processing all tenants sequentially
  2. For each tenant, up to 100 READY activities are dispatched per batch
  3. Each activity is sent to the provider configured for its channel
  4. On success, the activity transitions to DISPATCHED
  5. On failure, the activity retries (up to 3 attempts) before being marked FAILED

Dispatch Providers

Providers are pluggable implementations that handle the actual delivery:

ProviderCodeDescription
YOMYOMREST dispatch via POST {baseUrl}/activities with x-api-key header
MockMOCKReturns success with random UUID (development/testing)

Configuring a Provider

To receive activities from Reten, you need to configure a Dispatch Provider Channel Config that links a provider to a specific channel for your tenant.

Channel Config Properties

PropertyDescription
Base URLYour provider's endpoint URL
Encrypted credentialsAuthentication details (encrypted at rest with AES-256-GCM)
SettingsAdditional provider-specific configuration (JSON)

Use the Dispatch Config endpoints to manage configurations.

Channel Definitions

Each dispatch provider declares which channels it supports via Channel Definitions. These define the required credential and settings fields per channel, enabling dynamic configuration.

Dispatch Flow Detail

For each activity being dispatched:

  1. Optimistic lock — Increment dispatch_attempt_count atomically; skip if another process already locked it
  2. Load activity with relations (task details, operator, commerce assignment)
  3. Resolve dispatch config — Find the channel config matching the activity's channel
  4. Decrypt credentials using AES-256-GCM
  5. Look up provider code from the config
  6. Invoke dispatcher — Call the registered dispatcher for the provider
  7. On success — Set status to DISPATCHED, store providerActivityId and dispatchConfigId
  8. On failure — If attempts >= 3, set status to FAILED; otherwise keep READY for retry

Constants

ConstantValueDescription
Max dispatch attempts3Retries before marking FAILED
Batch size100Activities per cron batch per tenant
Cron interval30 secondsHow often the scheduler runs

What You Receive

When Reten dispatches an activity to your provider, the payload includes:

  • Activity details (type, channel, reason, scheduling)
  • Commerce information (assignment, target users)
  • Operator details (for TASK type)
  • Activity attributes (key-value data)

Your provider endpoint should accept this payload and return a provider activity ID that Reten stores for tracking.

Submitting Results Back

After processing an activity, submit results back to Reten via the Activity Results API. Link results using either the Reten activityId or your providerActivityId.