Automated tasks
Raise tasks from product module code and lifecycle hooks
Automated tasks
Automated tasks let your product logic raise a task for a human to action in response to something that happens on the platform — for example, flagging a policy for manual review when it breaches an SLA, or opening a follow-up task when a claim is approved.
Automated tasks always have the type automated, and are created from product module code — either directly through the Root SDK, or by returning a create_task action from a lifecycle hook.
AvailabilityLike the rest of task management, automated tasks require the
task_managementfeature flag. If the flag is not enabled,create_taskcalls are skipped with a warning rather than raising a task.
Creating a task from the SDK
Within product module code you can create a task directly using client.tasks.createTask:
await client.tasks.createTask({
type: 'automated',
name: 'Review flagged policy',
description: 'Policy exceeded its underwriting SLA and needs manual review.',
priority: 'high',
referenceType: 'policy',
referenceId: policy.policyId,
triggerKey: 'underwriting.sla_breached',
dedupeKey: `underwriting.sla_breached:${policy.policyId}`,
});Supported parameters:
| Parameter | Required | Description |
|---|---|---|
type | Yes | Always automated for tasks raised from code. |
name | Yes | The task's title. |
priority | Yes | A configured priority, e.g. high. |
description | No | Longer detail for whoever picks up the task. |
status | No | A configured status; defaults to the initial status. |
assignedToUserId | No | Assign the task to a specific user. |
assignedToGroupId | No | Assign the task to a user group. |
referenceType | No | The linked entity type (policy, claim, …). |
referenceId | No | The linked entity's id. |
dueDate | No | An explicit due date. |
slaHours | No | An SLA in hours, used to derive the due date. |
triggerKey | No | Identifies the automation that raised the task. |
dedupeKey | No | Idempotency key — see below. |
Using the create_task lifecycle-hook action
create_task lifecycle-hook actionLifecycle hooks can return a create_task action, which the platform executes on your behalf. This is the simplest way to raise a task from an event in a policy or claim's lifecycle. The action always creates a task of type automated, and defaults referenceType to policy. If you set referenceType to claim, a claim must be in scope for the hook.
Reference types for automated tasksAutomated task creation currently supports linking to a
policy(the default) or aclaim. Other reference types are available for manually created tasks.
Avoiding duplicates with triggerKey and dedupeKey
triggerKey and dedupeKeyAutomations often re-run — a scheduled function might evaluate the same policy every night. To prevent a fresh task being raised on every run, use the two idempotency fields:
triggerKeyidentifies which automation raised the task (for exampleunderwriting.sla_breached). It is useful for grouping and reporting.dedupeKeyis an idempotency key. While an open task with the samededupeKeyalready exists for the organisation and environment,createTaskdoes nothing and returns the existing task.
Because the dedupe key is cleared once a task reaches a terminal status (done or cancelled), a recurring trigger raises exactly one open task at a time: it won't pile up duplicates while the task is still open, but it can raise a new one after the previous task has been resolved.
A good pattern is to build the dedupeKey from the trigger and the entity it concerns:
dedupeKey: `underwriting.sla_breached:${policy.policyId}`Updated about 2 hours ago