# Triggered Automations ## Create a triggered automation (state + changeset filter trees) `client.TriggeredAutomations.New(ctx, automationObjectType, params) (*TriggeredAutomation, error)` **post** `/v2/prism/{teamId}/{automationObjectType}/triggered_automations` Create a triggered automation (state + changeset filter trees) ### Parameters - `automationObjectType TriggeredAutomationNewParamsAutomationObjectType` Object types that support triggered automations. Must match the triggered-automation whitelist in @micro/database migrate-sql (TRIGGERED_AUTOMATION_OBJECTS). - `const TriggeredAutomationNewParamsAutomationObjectTypeMessage TriggeredAutomationNewParamsAutomationObjectType = "message"` - `const TriggeredAutomationNewParamsAutomationObjectTypeAction TriggeredAutomationNewParamsAutomationObjectType = "action"` - `const TriggeredAutomationNewParamsAutomationObjectTypeEvent TriggeredAutomationNewParamsAutomationObjectType = "event"` - `const TriggeredAutomationNewParamsAutomationObjectTypeDocument TriggeredAutomationNewParamsAutomationObjectType = "document"` - `const TriggeredAutomationNewParamsAutomationObjectTypeIdentity TriggeredAutomationNewParamsAutomationObjectType = "identity"` - `const TriggeredAutomationNewParamsAutomationObjectTypeLinkedinMessage TriggeredAutomationNewParamsAutomationObjectType = "linkedin_message"` - `const TriggeredAutomationNewParamsAutomationObjectTypeDeal TriggeredAutomationNewParamsAutomationObjectType = "deal"` - `const TriggeredAutomationNewParamsAutomationObjectTypeOrganization TriggeredAutomationNewParamsAutomationObjectType = "organization"` - `const TriggeredAutomationNewParamsAutomationObjectTypeContact TriggeredAutomationNewParamsAutomationObjectType = "contact"` - `params TriggeredAutomationNewParams` - `TeamID param.Field[string]` Path param - `TriggeredAutomation param.Field[TriggeredAutomation]` Body param: A triggered automation. `kind` selects the shape: `update` fires on object updates and requires a `changeset` (from/to transition) filter plus an optional `state` precondition; `lifecycle` fires on create and/or delete (`on_create`/`on_delete`) and requires a `state` filter (no changeset). `state` permits dot-paths (nested reference filters); `changeset` is direct properties only. Object type is taken from the path. - `IdempotencyKey param.Field[string]` Header param: A unique key (UUID or any opaque string up to 255 chars) for an authenticated POST, PUT, or PATCH request. The server retains the initial claim for 24 hours and replays a completed non-5xx response only when the method, path, and request body all match. Reusing a non-expired key with a different method, path, or body returns 409 `idempotency_key_mismatch`; reusing it after expiry returns 409 `idempotency_key_stale`, so use a new key. Replays include the `idempotent-replay: true` response header. ### Returns - `type TriggeredAutomation struct{…}` A triggered automation. `kind` selects the shape: `update` fires on object updates and requires a `changeset` (from/to transition) filter plus an optional `state` precondition; `lifecycle` fires on create and/or delete (`on_create`/`on_delete`) and requires a `state` filter (no changeset). `state` permits dot-paths (nested reference filters); `changeset` is direct properties only. Object type is taken from the path. - `Kind TriggeredAutomationKind` - `const TriggeredAutomationKindUpdate TriggeredAutomationKind = "update"` - `const TriggeredAutomationKindLifecycle TriggeredAutomationKind = "lifecycle"` - `Name string` - `ID string` - `Actions []TriggeredAutomationAction` Actions to run when the automation fires; each item has a `type` plus type-specific fields. - `Type TriggeredAutomationActionsType` - `const TriggeredAutomationActionsTypeAgent TriggeredAutomationActionsType = "agent"` - `const TriggeredAutomationActionsTypeWebhook TriggeredAutomationActionsType = "webhook"` - `const TriggeredAutomationActionsTypeWait TriggeredAutomationActionsType = "wait"` - `const TriggeredAutomationActionsTypeEmail TriggeredAutomationActionsType = "email"` - `const TriggeredAutomationActionsTypeLinkedin TriggeredAutomationActionsType = "linkedin"` - `AgentID string` Required when `type` is `agent`. The agent to run. - `CronExpression string` wait: cron schedule for the resume time. Exactly one of delay_seconds or cron_expression. - `DelaySeconds int64` wait: relative delay in seconds. Exactly one of delay_seconds or cron_expression. - `RecipientEmailPropDefID string` Required when `type` is `email`. The property (on the recipient view object) holding the recipient email address. - `RecipientProviderPropDefID string` Required when `type` is `linkedin`. The property (on the recipient view object) holding the recipient LinkedIn provider id. - `RecipientViewID string` Required when `type` is `email` or `linkedin`. The saved prism view resolved at send time to the recipient audience (its filter re-runs each step, so responders drop out of later drip sends). - `RecipientViewObjectType string` Required when `type` is `email` or `linkedin`. Must be `contact` — the recipient audience is a contact view (contacts carry the direct email / linkedin provider property). - `SendAsUserID string` Required when `type` is `email` or `linkedin`. The user (external id) the message is sent as. - `Subject string` Required when `type` is `email`. The subject line; rendered as a Liquid template per recipient. - `TemplateID string` Required when `type` is `email` or `linkedin`. The email-template document whose body is rendered (Liquid) per recipient. - `Timezone string` wait: IANA timezone for evaluating cron_expression (optional). - `WebhookID string` Required when `type` is `webhook`. The id of the webhook the event is dispatched to (async) when the automation fires. - `Changeset TriggeredAutomationChangeset` A changeset filter group (update automations only): a combinator plus an array of transition clauses matching what is changing. Dot-paths (nested reference filters) are NOT permitted — direct properties only. - `Combinator TriggeredAutomationChangesetCombinator` - `const TriggeredAutomationChangesetCombinatorAnd TriggeredAutomationChangesetCombinator = "AND"` - `const TriggeredAutomationChangesetCombinatorOr TriggeredAutomationChangesetCombinator = "OR"` - `Filter []map[string, unknown]` Each entry is a transition clause { slug: { from?: { comparator: value }, to?: { comparator: value } } }. `from` matches the prior value, `to` the new value; an empty body { slug: {} } matches any change to that property. - `CreatedAt string` - `Enabled bool` - `ListID string` - `OnCreate bool` Lifecycle automations only. - `OnDelete bool` Lifecycle automations only. - `State TriggeredAutomationState` A filter group: a combinator plus an array of slug-based clauses. Dot-paths (e.g. `organization.location`) express nested reference filters. - `Combinator TriggeredAutomationStateCombinator` - `const TriggeredAutomationStateCombinatorAnd TriggeredAutomationStateCombinator = "AND"` - `const TriggeredAutomationStateCombinatorOr TriggeredAutomationStateCombinator = "OR"` - `Filter []map[string, unknown]` Each entry is { slug: { comparator: value } } - `TeamID string` - `UpdatedAt string` - `UserID string` ### Example ```go package main import ( "context" "fmt" "github.com/micro-so/micro-sdk-go" "github.com/micro-so/micro-sdk-go/option" ) func main() { client := micro.NewClient( option.WithAPIKey("My API Key"), option.WithTeamID("My Team ID"), ) triggeredAutomation, err := client.TriggeredAutomations.New( context.TODO(), micro.TriggeredAutomationNewParamsAutomationObjectTypeMessage, micro.TriggeredAutomationNewParams{ TriggeredAutomation: micro.TriggeredAutomationParam{ Kind: micro.F(micro.TriggeredAutomationKindUpdate), Name: micro.F("name"), }, }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", triggeredAutomation.ID) } ``` #### Response ```json { "kind": "update", "name": "name", "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "actions": [ { "type": "agent", "agent_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "cron_expression": "cron_expression", "delay_seconds": 0, "recipient_email_prop_def_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "recipient_provider_prop_def_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "recipient_view_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "recipient_view_object_type": "recipient_view_object_type", "send_as_user_id": "send_as_user_id", "subject": "subject", "template_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "timezone": "timezone", "webhook_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e" } ], "changeset": { "combinator": "AND", "filter": [ { "foo": "bar" } ] }, "created_at": "created_at", "enabled": true, "list_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "on_create": true, "on_delete": true, "state": { "combinator": "AND", "filter": [ { "foo": "bar" } ] }, "team_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "updated_at": "updated_at", "user_id": "user_id" } ``` ## List triggered automations for an owner `client.TriggeredAutomations.List(ctx, automationObjectType, params) (*TriggeredAutomationListResponse, error)` **get** `/v2/prism/{teamId}/{automationObjectType}/triggered_automations` List triggered automations for an owner ### Parameters - `automationObjectType TriggeredAutomationListParamsAutomationObjectType` Object types that support triggered automations. Must match the triggered-automation whitelist in @micro/database migrate-sql (TRIGGERED_AUTOMATION_OBJECTS). - `const TriggeredAutomationListParamsAutomationObjectTypeMessage TriggeredAutomationListParamsAutomationObjectType = "message"` - `const TriggeredAutomationListParamsAutomationObjectTypeAction TriggeredAutomationListParamsAutomationObjectType = "action"` - `const TriggeredAutomationListParamsAutomationObjectTypeEvent TriggeredAutomationListParamsAutomationObjectType = "event"` - `const TriggeredAutomationListParamsAutomationObjectTypeDocument TriggeredAutomationListParamsAutomationObjectType = "document"` - `const TriggeredAutomationListParamsAutomationObjectTypeIdentity TriggeredAutomationListParamsAutomationObjectType = "identity"` - `const TriggeredAutomationListParamsAutomationObjectTypeLinkedinMessage TriggeredAutomationListParamsAutomationObjectType = "linkedin_message"` - `const TriggeredAutomationListParamsAutomationObjectTypeDeal TriggeredAutomationListParamsAutomationObjectType = "deal"` - `const TriggeredAutomationListParamsAutomationObjectTypeOrganization TriggeredAutomationListParamsAutomationObjectType = "organization"` - `const TriggeredAutomationListParamsAutomationObjectTypeContact TriggeredAutomationListParamsAutomationObjectType = "contact"` - `params TriggeredAutomationListParams` - `TeamID param.Field[string]` Path param - `Cursor param.Field[string]` Query param: Opaque pagination cursor (from a prior response's next_cursor); supersedes page/limit when present. - `Kind param.Field[TriggeredAutomationListParamsKind]` Query param: Optional filter to a single automation kind. When omitted, both kinds are returned. - `const TriggeredAutomationListParamsKindUpdate TriggeredAutomationListParamsKind = "update"` - `const TriggeredAutomationListParamsKindLifecycle TriggeredAutomationListParamsKind = "lifecycle"` - `Limit param.Field[int64]` Query param: Maximum items per page (<= 50; defaults to 50). - `ListID param.Field[string]` Query param: List (CRM) id to scope the listing to. When omitted, automations owned by the path team are returned. - `Page param.Field[int64]` Query param: 1-based page number. Prefer cursor. ### Returns - `type TriggeredAutomationListResponse struct{…}` - `Data []TriggeredAutomation` - `Kind TriggeredAutomationKind` - `const TriggeredAutomationKindUpdate TriggeredAutomationKind = "update"` - `const TriggeredAutomationKindLifecycle TriggeredAutomationKind = "lifecycle"` - `Name string` - `ID string` - `Actions []TriggeredAutomationAction` Actions to run when the automation fires; each item has a `type` plus type-specific fields. - `Type TriggeredAutomationActionsType` - `const TriggeredAutomationActionsTypeAgent TriggeredAutomationActionsType = "agent"` - `const TriggeredAutomationActionsTypeWebhook TriggeredAutomationActionsType = "webhook"` - `const TriggeredAutomationActionsTypeWait TriggeredAutomationActionsType = "wait"` - `const TriggeredAutomationActionsTypeEmail TriggeredAutomationActionsType = "email"` - `const TriggeredAutomationActionsTypeLinkedin TriggeredAutomationActionsType = "linkedin"` - `AgentID string` Required when `type` is `agent`. The agent to run. - `CronExpression string` wait: cron schedule for the resume time. Exactly one of delay_seconds or cron_expression. - `DelaySeconds int64` wait: relative delay in seconds. Exactly one of delay_seconds or cron_expression. - `RecipientEmailPropDefID string` Required when `type` is `email`. The property (on the recipient view object) holding the recipient email address. - `RecipientProviderPropDefID string` Required when `type` is `linkedin`. The property (on the recipient view object) holding the recipient LinkedIn provider id. - `RecipientViewID string` Required when `type` is `email` or `linkedin`. The saved prism view resolved at send time to the recipient audience (its filter re-runs each step, so responders drop out of later drip sends). - `RecipientViewObjectType string` Required when `type` is `email` or `linkedin`. Must be `contact` — the recipient audience is a contact view (contacts carry the direct email / linkedin provider property). - `SendAsUserID string` Required when `type` is `email` or `linkedin`. The user (external id) the message is sent as. - `Subject string` Required when `type` is `email`. The subject line; rendered as a Liquid template per recipient. - `TemplateID string` Required when `type` is `email` or `linkedin`. The email-template document whose body is rendered (Liquid) per recipient. - `Timezone string` wait: IANA timezone for evaluating cron_expression (optional). - `WebhookID string` Required when `type` is `webhook`. The id of the webhook the event is dispatched to (async) when the automation fires. - `Changeset TriggeredAutomationChangeset` A changeset filter group (update automations only): a combinator plus an array of transition clauses matching what is changing. Dot-paths (nested reference filters) are NOT permitted — direct properties only. - `Combinator TriggeredAutomationChangesetCombinator` - `const TriggeredAutomationChangesetCombinatorAnd TriggeredAutomationChangesetCombinator = "AND"` - `const TriggeredAutomationChangesetCombinatorOr TriggeredAutomationChangesetCombinator = "OR"` - `Filter []map[string, unknown]` Each entry is a transition clause { slug: { from?: { comparator: value }, to?: { comparator: value } } }. `from` matches the prior value, `to` the new value; an empty body { slug: {} } matches any change to that property. - `CreatedAt string` - `Enabled bool` - `ListID string` - `OnCreate bool` Lifecycle automations only. - `OnDelete bool` Lifecycle automations only. - `State TriggeredAutomationState` A filter group: a combinator plus an array of slug-based clauses. Dot-paths (e.g. `organization.location`) express nested reference filters. - `Combinator TriggeredAutomationStateCombinator` - `const TriggeredAutomationStateCombinatorAnd TriggeredAutomationStateCombinator = "AND"` - `const TriggeredAutomationStateCombinatorOr TriggeredAutomationStateCombinator = "OR"` - `Filter []map[string, unknown]` Each entry is { slug: { comparator: value } } - `TeamID string` - `UpdatedAt string` - `UserID string` - `HasMore bool` True if more automations exist beyond this page. - `NextCursor string` Opaque cursor for the next page; null when has_more is false. ### Example ```go package main import ( "context" "fmt" "github.com/micro-so/micro-sdk-go" "github.com/micro-so/micro-sdk-go/option" ) func main() { client := micro.NewClient( option.WithAPIKey("My API Key"), option.WithTeamID("My Team ID"), ) triggeredAutomations, err := client.TriggeredAutomations.List( context.TODO(), micro.TriggeredAutomationListParamsAutomationObjectTypeMessage, micro.TriggeredAutomationListParams{ }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", triggeredAutomations.Data) } ``` #### Response ```json { "data": [ { "kind": "update", "name": "name", "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "actions": [ { "type": "agent", "agent_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "cron_expression": "cron_expression", "delay_seconds": 0, "recipient_email_prop_def_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "recipient_provider_prop_def_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "recipient_view_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "recipient_view_object_type": "recipient_view_object_type", "send_as_user_id": "send_as_user_id", "subject": "subject", "template_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "timezone": "timezone", "webhook_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e" } ], "changeset": { "combinator": "AND", "filter": [ { "foo": "bar" } ] }, "created_at": "created_at", "enabled": true, "list_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "on_create": true, "on_delete": true, "state": { "combinator": "AND", "filter": [ { "foo": "bar" } ] }, "team_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "updated_at": "updated_at", "user_id": "user_id" } ], "has_more": true, "next_cursor": "next_cursor" } ``` ## Read a triggered automation `client.TriggeredAutomations.Get(ctx, automationObjectType, automationID, query) (*TriggeredAutomation, error)` **get** `/v2/prism/{teamId}/{automationObjectType}/triggered_automations/{automationId}` Read a triggered automation ### Parameters - `automationObjectType TriggeredAutomationGetParamsAutomationObjectType` Object types that support triggered automations. Must match the triggered-automation whitelist in @micro/database migrate-sql (TRIGGERED_AUTOMATION_OBJECTS). - `const TriggeredAutomationGetParamsAutomationObjectTypeMessage TriggeredAutomationGetParamsAutomationObjectType = "message"` - `const TriggeredAutomationGetParamsAutomationObjectTypeAction TriggeredAutomationGetParamsAutomationObjectType = "action"` - `const TriggeredAutomationGetParamsAutomationObjectTypeEvent TriggeredAutomationGetParamsAutomationObjectType = "event"` - `const TriggeredAutomationGetParamsAutomationObjectTypeDocument TriggeredAutomationGetParamsAutomationObjectType = "document"` - `const TriggeredAutomationGetParamsAutomationObjectTypeIdentity TriggeredAutomationGetParamsAutomationObjectType = "identity"` - `const TriggeredAutomationGetParamsAutomationObjectTypeLinkedinMessage TriggeredAutomationGetParamsAutomationObjectType = "linkedin_message"` - `const TriggeredAutomationGetParamsAutomationObjectTypeDeal TriggeredAutomationGetParamsAutomationObjectType = "deal"` - `const TriggeredAutomationGetParamsAutomationObjectTypeOrganization TriggeredAutomationGetParamsAutomationObjectType = "organization"` - `const TriggeredAutomationGetParamsAutomationObjectTypeContact TriggeredAutomationGetParamsAutomationObjectType = "contact"` - `automationID string` - `query TriggeredAutomationGetParams` - `TeamID param.Field[string]` ### Returns - `type TriggeredAutomation struct{…}` A triggered automation. `kind` selects the shape: `update` fires on object updates and requires a `changeset` (from/to transition) filter plus an optional `state` precondition; `lifecycle` fires on create and/or delete (`on_create`/`on_delete`) and requires a `state` filter (no changeset). `state` permits dot-paths (nested reference filters); `changeset` is direct properties only. Object type is taken from the path. - `Kind TriggeredAutomationKind` - `const TriggeredAutomationKindUpdate TriggeredAutomationKind = "update"` - `const TriggeredAutomationKindLifecycle TriggeredAutomationKind = "lifecycle"` - `Name string` - `ID string` - `Actions []TriggeredAutomationAction` Actions to run when the automation fires; each item has a `type` plus type-specific fields. - `Type TriggeredAutomationActionsType` - `const TriggeredAutomationActionsTypeAgent TriggeredAutomationActionsType = "agent"` - `const TriggeredAutomationActionsTypeWebhook TriggeredAutomationActionsType = "webhook"` - `const TriggeredAutomationActionsTypeWait TriggeredAutomationActionsType = "wait"` - `const TriggeredAutomationActionsTypeEmail TriggeredAutomationActionsType = "email"` - `const TriggeredAutomationActionsTypeLinkedin TriggeredAutomationActionsType = "linkedin"` - `AgentID string` Required when `type` is `agent`. The agent to run. - `CronExpression string` wait: cron schedule for the resume time. Exactly one of delay_seconds or cron_expression. - `DelaySeconds int64` wait: relative delay in seconds. Exactly one of delay_seconds or cron_expression. - `RecipientEmailPropDefID string` Required when `type` is `email`. The property (on the recipient view object) holding the recipient email address. - `RecipientProviderPropDefID string` Required when `type` is `linkedin`. The property (on the recipient view object) holding the recipient LinkedIn provider id. - `RecipientViewID string` Required when `type` is `email` or `linkedin`. The saved prism view resolved at send time to the recipient audience (its filter re-runs each step, so responders drop out of later drip sends). - `RecipientViewObjectType string` Required when `type` is `email` or `linkedin`. Must be `contact` — the recipient audience is a contact view (contacts carry the direct email / linkedin provider property). - `SendAsUserID string` Required when `type` is `email` or `linkedin`. The user (external id) the message is sent as. - `Subject string` Required when `type` is `email`. The subject line; rendered as a Liquid template per recipient. - `TemplateID string` Required when `type` is `email` or `linkedin`. The email-template document whose body is rendered (Liquid) per recipient. - `Timezone string` wait: IANA timezone for evaluating cron_expression (optional). - `WebhookID string` Required when `type` is `webhook`. The id of the webhook the event is dispatched to (async) when the automation fires. - `Changeset TriggeredAutomationChangeset` A changeset filter group (update automations only): a combinator plus an array of transition clauses matching what is changing. Dot-paths (nested reference filters) are NOT permitted — direct properties only. - `Combinator TriggeredAutomationChangesetCombinator` - `const TriggeredAutomationChangesetCombinatorAnd TriggeredAutomationChangesetCombinator = "AND"` - `const TriggeredAutomationChangesetCombinatorOr TriggeredAutomationChangesetCombinator = "OR"` - `Filter []map[string, unknown]` Each entry is a transition clause { slug: { from?: { comparator: value }, to?: { comparator: value } } }. `from` matches the prior value, `to` the new value; an empty body { slug: {} } matches any change to that property. - `CreatedAt string` - `Enabled bool` - `ListID string` - `OnCreate bool` Lifecycle automations only. - `OnDelete bool` Lifecycle automations only. - `State TriggeredAutomationState` A filter group: a combinator plus an array of slug-based clauses. Dot-paths (e.g. `organization.location`) express nested reference filters. - `Combinator TriggeredAutomationStateCombinator` - `const TriggeredAutomationStateCombinatorAnd TriggeredAutomationStateCombinator = "AND"` - `const TriggeredAutomationStateCombinatorOr TriggeredAutomationStateCombinator = "OR"` - `Filter []map[string, unknown]` Each entry is { slug: { comparator: value } } - `TeamID string` - `UpdatedAt string` - `UserID string` ### Example ```go package main import ( "context" "fmt" "github.com/micro-so/micro-sdk-go" "github.com/micro-so/micro-sdk-go/option" ) func main() { client := micro.NewClient( option.WithAPIKey("My API Key"), option.WithTeamID("My Team ID"), ) triggeredAutomation, err := client.TriggeredAutomations.Get( context.TODO(), micro.TriggeredAutomationGetParamsAutomationObjectTypeMessage, "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", micro.TriggeredAutomationGetParams{ }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", triggeredAutomation.ID) } ``` #### Response ```json { "kind": "update", "name": "name", "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "actions": [ { "type": "agent", "agent_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "cron_expression": "cron_expression", "delay_seconds": 0, "recipient_email_prop_def_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "recipient_provider_prop_def_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "recipient_view_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "recipient_view_object_type": "recipient_view_object_type", "send_as_user_id": "send_as_user_id", "subject": "subject", "template_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "timezone": "timezone", "webhook_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e" } ], "changeset": { "combinator": "AND", "filter": [ { "foo": "bar" } ] }, "created_at": "created_at", "enabled": true, "list_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "on_create": true, "on_delete": true, "state": { "combinator": "AND", "filter": [ { "foo": "bar" } ] }, "team_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "updated_at": "updated_at", "user_id": "user_id" } ``` ## Replace a triggered automation (idempotent full write of the whole tree) `client.TriggeredAutomations.Update(ctx, automationObjectType, automationID, params) (*TriggeredAutomation, error)` **put** `/v2/prism/{teamId}/{automationObjectType}/triggered_automations/{automationId}` Replace a triggered automation (idempotent full write of the whole tree) ### Parameters - `automationObjectType TriggeredAutomationUpdateParamsAutomationObjectType` Object types that support triggered automations. Must match the triggered-automation whitelist in @micro/database migrate-sql (TRIGGERED_AUTOMATION_OBJECTS). - `const TriggeredAutomationUpdateParamsAutomationObjectTypeMessage TriggeredAutomationUpdateParamsAutomationObjectType = "message"` - `const TriggeredAutomationUpdateParamsAutomationObjectTypeAction TriggeredAutomationUpdateParamsAutomationObjectType = "action"` - `const TriggeredAutomationUpdateParamsAutomationObjectTypeEvent TriggeredAutomationUpdateParamsAutomationObjectType = "event"` - `const TriggeredAutomationUpdateParamsAutomationObjectTypeDocument TriggeredAutomationUpdateParamsAutomationObjectType = "document"` - `const TriggeredAutomationUpdateParamsAutomationObjectTypeIdentity TriggeredAutomationUpdateParamsAutomationObjectType = "identity"` - `const TriggeredAutomationUpdateParamsAutomationObjectTypeLinkedinMessage TriggeredAutomationUpdateParamsAutomationObjectType = "linkedin_message"` - `const TriggeredAutomationUpdateParamsAutomationObjectTypeDeal TriggeredAutomationUpdateParamsAutomationObjectType = "deal"` - `const TriggeredAutomationUpdateParamsAutomationObjectTypeOrganization TriggeredAutomationUpdateParamsAutomationObjectType = "organization"` - `const TriggeredAutomationUpdateParamsAutomationObjectTypeContact TriggeredAutomationUpdateParamsAutomationObjectType = "contact"` - `automationID string` - `params TriggeredAutomationUpdateParams` - `TeamID param.Field[string]` Path param - `TriggeredAutomation param.Field[TriggeredAutomation]` Body param: A triggered automation. `kind` selects the shape: `update` fires on object updates and requires a `changeset` (from/to transition) filter plus an optional `state` precondition; `lifecycle` fires on create and/or delete (`on_create`/`on_delete`) and requires a `state` filter (no changeset). `state` permits dot-paths (nested reference filters); `changeset` is direct properties only. Object type is taken from the path. - `IdempotencyKey param.Field[string]` Header param: A unique key (UUID or any opaque string up to 255 chars) for an authenticated POST, PUT, or PATCH request. The server retains the initial claim for 24 hours and replays a completed non-5xx response only when the method, path, and request body all match. Reusing a non-expired key with a different method, path, or body returns 409 `idempotency_key_mismatch`; reusing it after expiry returns 409 `idempotency_key_stale`, so use a new key. Replays include the `idempotent-replay: true` response header. ### Returns - `type TriggeredAutomation struct{…}` A triggered automation. `kind` selects the shape: `update` fires on object updates and requires a `changeset` (from/to transition) filter plus an optional `state` precondition; `lifecycle` fires on create and/or delete (`on_create`/`on_delete`) and requires a `state` filter (no changeset). `state` permits dot-paths (nested reference filters); `changeset` is direct properties only. Object type is taken from the path. - `Kind TriggeredAutomationKind` - `const TriggeredAutomationKindUpdate TriggeredAutomationKind = "update"` - `const TriggeredAutomationKindLifecycle TriggeredAutomationKind = "lifecycle"` - `Name string` - `ID string` - `Actions []TriggeredAutomationAction` Actions to run when the automation fires; each item has a `type` plus type-specific fields. - `Type TriggeredAutomationActionsType` - `const TriggeredAutomationActionsTypeAgent TriggeredAutomationActionsType = "agent"` - `const TriggeredAutomationActionsTypeWebhook TriggeredAutomationActionsType = "webhook"` - `const TriggeredAutomationActionsTypeWait TriggeredAutomationActionsType = "wait"` - `const TriggeredAutomationActionsTypeEmail TriggeredAutomationActionsType = "email"` - `const TriggeredAutomationActionsTypeLinkedin TriggeredAutomationActionsType = "linkedin"` - `AgentID string` Required when `type` is `agent`. The agent to run. - `CronExpression string` wait: cron schedule for the resume time. Exactly one of delay_seconds or cron_expression. - `DelaySeconds int64` wait: relative delay in seconds. Exactly one of delay_seconds or cron_expression. - `RecipientEmailPropDefID string` Required when `type` is `email`. The property (on the recipient view object) holding the recipient email address. - `RecipientProviderPropDefID string` Required when `type` is `linkedin`. The property (on the recipient view object) holding the recipient LinkedIn provider id. - `RecipientViewID string` Required when `type` is `email` or `linkedin`. The saved prism view resolved at send time to the recipient audience (its filter re-runs each step, so responders drop out of later drip sends). - `RecipientViewObjectType string` Required when `type` is `email` or `linkedin`. Must be `contact` — the recipient audience is a contact view (contacts carry the direct email / linkedin provider property). - `SendAsUserID string` Required when `type` is `email` or `linkedin`. The user (external id) the message is sent as. - `Subject string` Required when `type` is `email`. The subject line; rendered as a Liquid template per recipient. - `TemplateID string` Required when `type` is `email` or `linkedin`. The email-template document whose body is rendered (Liquid) per recipient. - `Timezone string` wait: IANA timezone for evaluating cron_expression (optional). - `WebhookID string` Required when `type` is `webhook`. The id of the webhook the event is dispatched to (async) when the automation fires. - `Changeset TriggeredAutomationChangeset` A changeset filter group (update automations only): a combinator plus an array of transition clauses matching what is changing. Dot-paths (nested reference filters) are NOT permitted — direct properties only. - `Combinator TriggeredAutomationChangesetCombinator` - `const TriggeredAutomationChangesetCombinatorAnd TriggeredAutomationChangesetCombinator = "AND"` - `const TriggeredAutomationChangesetCombinatorOr TriggeredAutomationChangesetCombinator = "OR"` - `Filter []map[string, unknown]` Each entry is a transition clause { slug: { from?: { comparator: value }, to?: { comparator: value } } }. `from` matches the prior value, `to` the new value; an empty body { slug: {} } matches any change to that property. - `CreatedAt string` - `Enabled bool` - `ListID string` - `OnCreate bool` Lifecycle automations only. - `OnDelete bool` Lifecycle automations only. - `State TriggeredAutomationState` A filter group: a combinator plus an array of slug-based clauses. Dot-paths (e.g. `organization.location`) express nested reference filters. - `Combinator TriggeredAutomationStateCombinator` - `const TriggeredAutomationStateCombinatorAnd TriggeredAutomationStateCombinator = "AND"` - `const TriggeredAutomationStateCombinatorOr TriggeredAutomationStateCombinator = "OR"` - `Filter []map[string, unknown]` Each entry is { slug: { comparator: value } } - `TeamID string` - `UpdatedAt string` - `UserID string` ### Example ```go package main import ( "context" "fmt" "github.com/micro-so/micro-sdk-go" "github.com/micro-so/micro-sdk-go/option" ) func main() { client := micro.NewClient( option.WithAPIKey("My API Key"), option.WithTeamID("My Team ID"), ) triggeredAutomation, err := client.TriggeredAutomations.Update( context.TODO(), micro.TriggeredAutomationUpdateParamsAutomationObjectTypeMessage, "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", micro.TriggeredAutomationUpdateParams{ TriggeredAutomation: micro.TriggeredAutomationParam{ Kind: micro.F(micro.TriggeredAutomationKindUpdate), Name: micro.F("name"), }, }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", triggeredAutomation.ID) } ``` #### Response ```json { "kind": "update", "name": "name", "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "actions": [ { "type": "agent", "agent_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "cron_expression": "cron_expression", "delay_seconds": 0, "recipient_email_prop_def_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "recipient_provider_prop_def_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "recipient_view_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "recipient_view_object_type": "recipient_view_object_type", "send_as_user_id": "send_as_user_id", "subject": "subject", "template_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "timezone": "timezone", "webhook_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e" } ], "changeset": { "combinator": "AND", "filter": [ { "foo": "bar" } ] }, "created_at": "created_at", "enabled": true, "list_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "on_create": true, "on_delete": true, "state": { "combinator": "AND", "filter": [ { "foo": "bar" } ] }, "team_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "updated_at": "updated_at", "user_id": "user_id" } ``` ## Delete a triggered automation and its filter trees `client.TriggeredAutomations.Delete(ctx, automationObjectType, automationID, body) error` **delete** `/v2/prism/{teamId}/{automationObjectType}/triggered_automations/{automationId}` Delete a triggered automation and its filter trees ### Parameters - `automationObjectType TriggeredAutomationDeleteParamsAutomationObjectType` Object types that support triggered automations. Must match the triggered-automation whitelist in @micro/database migrate-sql (TRIGGERED_AUTOMATION_OBJECTS). - `const TriggeredAutomationDeleteParamsAutomationObjectTypeMessage TriggeredAutomationDeleteParamsAutomationObjectType = "message"` - `const TriggeredAutomationDeleteParamsAutomationObjectTypeAction TriggeredAutomationDeleteParamsAutomationObjectType = "action"` - `const TriggeredAutomationDeleteParamsAutomationObjectTypeEvent TriggeredAutomationDeleteParamsAutomationObjectType = "event"` - `const TriggeredAutomationDeleteParamsAutomationObjectTypeDocument TriggeredAutomationDeleteParamsAutomationObjectType = "document"` - `const TriggeredAutomationDeleteParamsAutomationObjectTypeIdentity TriggeredAutomationDeleteParamsAutomationObjectType = "identity"` - `const TriggeredAutomationDeleteParamsAutomationObjectTypeLinkedinMessage TriggeredAutomationDeleteParamsAutomationObjectType = "linkedin_message"` - `const TriggeredAutomationDeleteParamsAutomationObjectTypeDeal TriggeredAutomationDeleteParamsAutomationObjectType = "deal"` - `const TriggeredAutomationDeleteParamsAutomationObjectTypeOrganization TriggeredAutomationDeleteParamsAutomationObjectType = "organization"` - `const TriggeredAutomationDeleteParamsAutomationObjectTypeContact TriggeredAutomationDeleteParamsAutomationObjectType = "contact"` - `automationID string` - `body TriggeredAutomationDeleteParams` - `TeamID param.Field[string]` ### Example ```go package main import ( "context" "github.com/micro-so/micro-sdk-go" "github.com/micro-so/micro-sdk-go/option" ) func main() { client := micro.NewClient( option.WithAPIKey("My API Key"), option.WithTeamID("My Team ID"), ) err := client.TriggeredAutomations.Delete( context.TODO(), micro.TriggeredAutomationDeleteParamsAutomationObjectTypeMessage, "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", micro.TriggeredAutomationDeleteParams{ }, ) if err != nil { panic(err.Error()) } } ``` ## Domain Types ### Triggered Automation - `type TriggeredAutomation struct{…}` A triggered automation. `kind` selects the shape: `update` fires on object updates and requires a `changeset` (from/to transition) filter plus an optional `state` precondition; `lifecycle` fires on create and/or delete (`on_create`/`on_delete`) and requires a `state` filter (no changeset). `state` permits dot-paths (nested reference filters); `changeset` is direct properties only. Object type is taken from the path. - `Kind TriggeredAutomationKind` - `const TriggeredAutomationKindUpdate TriggeredAutomationKind = "update"` - `const TriggeredAutomationKindLifecycle TriggeredAutomationKind = "lifecycle"` - `Name string` - `ID string` - `Actions []TriggeredAutomationAction` Actions to run when the automation fires; each item has a `type` plus type-specific fields. - `Type TriggeredAutomationActionsType` - `const TriggeredAutomationActionsTypeAgent TriggeredAutomationActionsType = "agent"` - `const TriggeredAutomationActionsTypeWebhook TriggeredAutomationActionsType = "webhook"` - `const TriggeredAutomationActionsTypeWait TriggeredAutomationActionsType = "wait"` - `const TriggeredAutomationActionsTypeEmail TriggeredAutomationActionsType = "email"` - `const TriggeredAutomationActionsTypeLinkedin TriggeredAutomationActionsType = "linkedin"` - `AgentID string` Required when `type` is `agent`. The agent to run. - `CronExpression string` wait: cron schedule for the resume time. Exactly one of delay_seconds or cron_expression. - `DelaySeconds int64` wait: relative delay in seconds. Exactly one of delay_seconds or cron_expression. - `RecipientEmailPropDefID string` Required when `type` is `email`. The property (on the recipient view object) holding the recipient email address. - `RecipientProviderPropDefID string` Required when `type` is `linkedin`. The property (on the recipient view object) holding the recipient LinkedIn provider id. - `RecipientViewID string` Required when `type` is `email` or `linkedin`. The saved prism view resolved at send time to the recipient audience (its filter re-runs each step, so responders drop out of later drip sends). - `RecipientViewObjectType string` Required when `type` is `email` or `linkedin`. Must be `contact` — the recipient audience is a contact view (contacts carry the direct email / linkedin provider property). - `SendAsUserID string` Required when `type` is `email` or `linkedin`. The user (external id) the message is sent as. - `Subject string` Required when `type` is `email`. The subject line; rendered as a Liquid template per recipient. - `TemplateID string` Required when `type` is `email` or `linkedin`. The email-template document whose body is rendered (Liquid) per recipient. - `Timezone string` wait: IANA timezone for evaluating cron_expression (optional). - `WebhookID string` Required when `type` is `webhook`. The id of the webhook the event is dispatched to (async) when the automation fires. - `Changeset TriggeredAutomationChangeset` A changeset filter group (update automations only): a combinator plus an array of transition clauses matching what is changing. Dot-paths (nested reference filters) are NOT permitted — direct properties only. - `Combinator TriggeredAutomationChangesetCombinator` - `const TriggeredAutomationChangesetCombinatorAnd TriggeredAutomationChangesetCombinator = "AND"` - `const TriggeredAutomationChangesetCombinatorOr TriggeredAutomationChangesetCombinator = "OR"` - `Filter []map[string, unknown]` Each entry is a transition clause { slug: { from?: { comparator: value }, to?: { comparator: value } } }. `from` matches the prior value, `to` the new value; an empty body { slug: {} } matches any change to that property. - `CreatedAt string` - `Enabled bool` - `ListID string` - `OnCreate bool` Lifecycle automations only. - `OnDelete bool` Lifecycle automations only. - `State TriggeredAutomationState` A filter group: a combinator plus an array of slug-based clauses. Dot-paths (e.g. `organization.location`) express nested reference filters. - `Combinator TriggeredAutomationStateCombinator` - `const TriggeredAutomationStateCombinatorAnd TriggeredAutomationStateCombinator = "AND"` - `const TriggeredAutomationStateCombinatorOr TriggeredAutomationStateCombinator = "OR"` - `Filter []map[string, unknown]` Each entry is { slug: { comparator: value } } - `TeamID string` - `UpdatedAt string` - `UserID string`